class PrintableCalendar::Range
Public Class Methods
compute(period, startingFrom)
click to toggle source
# File lib/printable_calendar/range.rb, line 22 def self.compute(period, startingFrom) t = startingFrom mapper = range_map[period.to_sym] abort "Unknown period #{period}. Use one of {#{supported_periods.join(", ")}}" unless mapper s, e = mapper.(t) [s.beginning_of_day, e.end_of_day] end
range_map()
click to toggle source
# File lib/printable_calendar/range.rb, line 8 def self.range_map { work_week: ->(t){[t.beginning_of_week(:monday), t.beginning_of_week(:monday) + 4]}, american_week: ->(t){[t.beginning_of_week(:sunday), t.end_of_week(:sunday)]}, intl_week: ->(t){[t.beginning_of_week(:monday), t.end_of_week(:sunday)]}, month: ->(t){[t.beginning_of_month, t.end_of_month]}, day: ->(t){[t, t]} } end
supported_periods()
click to toggle source
# File lib/printable_calendar/range.rb, line 18 def self.supported_periods range_map.keys.map{|k| k.to_s} end