Class: Vobject::Component
- Inherits:
-
Object
- Object
- Vobject::Component
- Defined in:
- lib/vobject/component.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#comp_name ⇒ Object
Returns the value of attribute comp_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, cs) ⇒ Component
constructor
A new instance of Component.
- #to_s ⇒ Object
Constructor Details
#initialize(key, cs) ⇒ Component
Returns a new instance of Component.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vobject/component.rb', line 25 def initialize key, cs self.comp_name = key raise_invalid_initialization if key != name self.children = cs.map do |c| key = c.keys.first val = c[key] cc = child_class(key, val) cc.new key, val end end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
6 7 8 |
# File 'lib/vobject/component.rb', line 6 def children @children end |
#comp_name ⇒ Object
Returns the value of attribute comp_name.
6 7 8 |
# File 'lib/vobject/component.rb', line 6 def comp_name @comp_name end |
Class Method Details
.parse(vcf) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/vobject/component.rb', line 10 def parse(vcf) hash = Vobject.parse(vcf) comp_name = hash.keys.first self.new comp_name, hash[comp_name] end |
Instance Method Details
#to_s ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vobject/component.rb', line 39 def to_s s = "BEGIN:#{name}\n" children.each do |c| s << c.to_s end s << "END:#{name}\n" s end |