Class: Carendar::Calendar
- Inherits:
-
Object
- Object
- Carendar::Calendar
- Defined in:
- lib/carendar.rb
Instance Attribute Summary collapse
-
#days ⇒ Object
readonly
Returns the value of attribute days.
Instance Method Summary collapse
-
#initialize(from, to, item_hashes) ⇒ Calendar
constructor
A new instance of Calendar.
Constructor Details
#initialize(from, to, item_hashes) ⇒ Calendar
Returns a new instance of Calendar.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# 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 |
Instance Attribute Details
#days ⇒ Object (readonly)
Returns the value of attribute days.
77 78 79 |
# File 'lib/carendar.rb', line 77 def days @days end |