Class: Icalendar::Component

Inherits:
Object
  • Object
show all
Includes:
HasComponents, HasProperties
Defined in:
lib/icalendar/component.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasComponents

#add_component, included, #method_missing, #respond_to_missing?

Methods included from HasProperties

#append_custom_property, #custom_property, included, #method_missing, #property, #respond_to_missing?, #valid?

Constructor Details

#initialize(name, ical_name = nil) ⇒ Component

Returns a new instance of Component.



19
20
21
22
23
# File 'lib/icalendar/component.rb', line 19

def initialize(name, ical_name = nil)
  @name = name
  @ical_name = ical_name || "V#{name.upcase}"
  super()
end

Dynamic Method Handling

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

Instance Attribute Details

#ical_nameObject (readonly)

Returns the value of attribute ical_name.



10
11
12
# File 'lib/icalendar/component.rb', line 10

def ical_name
  @ical_name
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/icalendar/component.rb', line 9

def name
  @name
end

#parentObject

Returns the value of attribute parent.



11
12
13
# File 'lib/icalendar/component.rb', line 11

def parent
  @parent
end

Class Method Details

.parse(source) ⇒ Object



13
14
15
16
17
# File 'lib/icalendar/component.rb', line 13

def self.parse(source)
  parser = Parser.new(source)
  parser.component_class = self
  parser.parse
end

Instance Method Details

#new_uidObject



25
26
27
# File 'lib/icalendar/component.rb', line 25

def new_uid
  SecureRandom.uuid
end

#to_icalObject



29
30
31
32
33
34
35
36
# File 'lib/icalendar/component.rb', line 29

def to_ical
  [
    "BEGIN:#{ical_name}",
    ical_properties,
    ical_components,
    "END:#{ical_name}\r\n"
  ].compact.join "\r\n"
end