Class: Icalendar::Calendar

Inherits:
Component show all
Defined in:
lib/icalendar/calendar.rb

Instance Attribute Summary collapse

Attributes inherited from Component

#name, #properties, #property_params

Instance Method Summary collapse

Methods inherited from Component

#method_missing, #print_string

Constructor Details

#initializeCalendar

Returns a new instance of Calendar.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/icalendar/calendar.rb', line 6

def initialize()
  super("VCALENDAR")
  @properties = {}
  @property_params = {}
  
  @events = []
  @todos = []
  @journals = []
  @freebusys = []
  @timezones = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Icalendar::Component

Instance Attribute Details

#eventsObject

Returns the value of attribute events.



4
5
6
# File 'lib/icalendar/calendar.rb', line 4

def events
  @events
end

#freebusysObject

Returns the value of attribute freebusys.



4
5
6
# File 'lib/icalendar/calendar.rb', line 4

def freebusys
  @freebusys
end

#journalsObject

Returns the value of attribute journals.



4
5
6
# File 'lib/icalendar/calendar.rb', line 4

def journals
  @journals
end

#timezonesObject

Returns the value of attribute timezones.



4
5
6
# File 'lib/icalendar/calendar.rb', line 4

def timezones
  @timezones
end

#todosObject

Returns the value of attribute todos.



4
5
6
# File 'lib/icalendar/calendar.rb', line 4

def todos
  @todos
end

Instance Method Details

#add(component) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/icalendar/calendar.rb', line 18

def add(component)
  if component.is_a? Event
      @events << component
    elsif component.is_a? Todo
      @todos << component
    elsif component.is_a? Journal
      @journals << component
    elsif component.is_a? Freebusy
      @freebusys << component
    elsif component.is_a? Timezone
      @timezones << component
    else
      raise InvalidComponentClass
  end
end

#to_sObject



34
35
36
37
38
39
40
41
42
# File 'lib/icalendar/calendar.rb', line 34

def to_s
  print_string do |s|
    @events.each { |event| s << event.to_s }
    @todos.each { |todo| s << todo.to_s }
    @journals.each { |journal| s << journal.to_s }
    @freebusys.each { |freebusy| s << freebusy.to_s }
    @timezones.each { |timezone| s << timezone.to_s }
  end
end