module Workhours::Util
Public Instance Methods
int_to_wday(num)
click to toggle source
# File lib/workhours/util.rb, line 7 def int_to_wday(num) ALL_DAYS[num] end
is_today?(day_name, time)
click to toggle source
# File lib/workhours/util.rb, line 18 def is_today?(day_name, time) time.wday == wday_to_int(day_name) end
is_tomorrow?(day_name, time)
click to toggle source
# File lib/workhours/util.rb, line 21 def is_tomorrow?(day_name, time) time.wday == wday_to_int(next_day(day_name)) end
is_yesterday?(day_name, time)
click to toggle source
# File lib/workhours/util.rb, line 24 def is_yesterday?(day_name, time) time.wday == wday_to_int(prev_day(day_name)) end
next_day(day_name)
click to toggle source
# File lib/workhours/util.rb, line 11 def next_day(day_name) int_to_wday((wday_to_int(day_name) + 1) % 7) end
prev_day(day_name)
click to toggle source
# File lib/workhours/util.rb, line 14 def prev_day(day_name) int_to_wday((wday_to_int(day_name) + 6) % 7) end
wday_to_int(day_name)
click to toggle source
# File lib/workhours/util.rb, line 3 def wday_to_int(day_name) ALL_DAYS.find_index(day_name.to_s.downcase) end