class Carendar::Calendar
Attributes
days[R]
Public Class Methods
new(from, to, item_hashes)
click to toggle source
# File lib/carendar.rb, line 78 def initialize(from, to, item_hashes) items_by_day = item_hashes.group_by do |item_hash| item_hash[:starts_at].beginning_of_day end beginning_of_calendar = from.beginning_of_week end_of_calendar = to.end_of_week current_day = beginning_of_calendar @days = [] while (current_day <= end_of_calendar) do @days << CalendarDay.new(current_day, items_by_day[current_day] || []) current_day += 1.day end end