Class: WaffleCal::Calendar

Inherits:
Object
  • Object
show all
Defined in:
lib/waffle_cal/calendar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#eventsObject

Returns the value of attribute events.



5
6
7
# File 'lib/waffle_cal/calendar.rb', line 5

def events
  @events
end

#prod_idObject

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_sObject



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