Class: WaffleCal::Calendar
- Inherits:
-
Object
- Object
- WaffleCal::Calendar
- Defined in:
- lib/waffle_cal/calendar.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
-
#prod_id ⇒ Object
Returns the value of attribute prod_id.
Instance Method Summary collapse
- #<<(event) ⇒ Object
- #add_event(event) ⇒ Object
-
#initialize(prod_id = nil) ⇒ Calendar
constructor
A new instance of Calendar.
- #to_s ⇒ Object
Constructor Details
#initialize(prod_id = nil) ⇒ Calendar
Returns a new instance of Calendar.
7 8 9 |
# File 'lib/waffle_cal/calendar.rb', line 7 def initialize(prod_id=nil) @prod_id = prod_id end |
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events.
5 6 7 |
# File 'lib/waffle_cal/calendar.rb', line 5 def events @events end |
#prod_id ⇒ Object
Returns the value of attribute prod_id.
5 6 7 |
# File 'lib/waffle_cal/calendar.rb', line 5 def prod_id @prod_id end |
Instance Method Details
#<<(event) ⇒ Object
11 12 13 |
# File 'lib/waffle_cal/calendar.rb', line 11 def <<(event) add_event(event) end |
#add_event(event) ⇒ Object
15 16 17 18 |
# File 'lib/waffle_cal/calendar.rb', line 15 def add_event(event) @events ||= [] @events << event end |
#to_s ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/waffle_cal/calendar.rb', line 24 def to_s output = [] output += start_calendar output += events.collect { |evt| evt.to_s } output += end_calendar output.join("\r\n") end |