class Weekend::Base
Public Class Methods
filter_weekdays(start_date, end_date)
click to toggle source
filter weekdays
# File lib/Weekend/base.rb, line 9 def filter_weekdays start_date, end_date result(start_date,end_date,[0,6]) end
filter_weekends(start_date, end_date)
click to toggle source
Filtering weekends
# File lib/Weekend/base.rb, line 4 def filter_weekends start_date, end_date result(start_date,end_date,[1,2,3,4,5]) end
no_of_weekends(start_date, end_date)
click to toggle source
no of weekends
# File lib/Weekend/base.rb, line 19 def no_of_weekends start_date, end_date filter_weekdays(start_date,end_date).count end
no_of_working_days(start_date, end_date)
click to toggle source
total working days(except weekends)
# File lib/Weekend/base.rb, line 14 def no_of_working_days start_date, end_date filter_weekends(start_date,end_date).count end
result(start_date, end_date, arr_of_days)
click to toggle source
# File lib/Weekend/base.rb, line 23 def result start_date, end_date, arr_of_days ((start_date.to_date)..(end_date.to_date)).to_a.select {|k| arr_of_days.include?(k.wday)} end