Class: Vobject::Component::Vcalendar
- Inherits:
-
Vobject::Component
- Object
- Vobject::Component
- Vobject::Component::Vcalendar
- Defined in:
- lib/vobject/vcalendar/component.rb
Direct Known Subclasses
Alarm, Event, Freebusy, Journal, Timezone, ToDo, Vavailability, Vavailability::Available
Defined Under Namespace
Classes: Alarm, Event, Freebusy, Journal, Timezone, ToDo, Vavailability
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#comp_name ⇒ Object
Returns the value of attribute comp_name.
Attributes inherited from Vobject::Component
#errors, #multiple_components, #norm
Class Method Summary collapse
Methods inherited from Vobject::Component
#<=>, #blank, #child_class, #get_errors, #initialize, #name, #to_hash, #to_json, #to_norm, #to_s
Constructor Details
This class inherits a constructor from Vobject::Component
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
7 8 9 |
# File 'lib/vobject/vcalendar/component.rb', line 7 def children @children end |
#comp_name ⇒ Object
Returns the value of attribute comp_name.
7 8 9 |
# File 'lib/vobject/vcalendar/component.rb', line 7 def comp_name @comp_name end |
Class Method Details
.child_class(key, val) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/vobject/vcalendar/component.rb', line 48 def child_class(key, val) base_class = if key == :VTODO Vobject::Component::Vcalendar::ToDo elsif key == :VFREEBUSY Vobject::Component::Vcalendar::FreeBusy elsif key == :JOURNAL Vobject::Component::Vcalendar::Journal elsif key == :STANDARD Vobject::Component::Vcalendar::Timezone::Standard elsif key == :DAYLIGHT Vobject::Component::Vcalendar::Timezone::Daylight elsif key == :VTIMEZONE Vobject::Component::Vcalendar::Timezone elsif key == :VEVENT Vobject::Component::Vcalendar::Event elsif key == :VALARM Vobject::Component::Vcalendar::Alarm elsif key == :VAVAILABILITY Vobject::Component::Vcalendar::Vavailability elsif key == :AVAILABLE Vobject::Component::Vcalendar::Vavailability::Available elsif !(val.is_a?(Hash) && !val.has_key?(:value)) property_base_class else Vobject::Component::Vcalendar end return base_class if [:CLASS, :OBJECT, :METHOD].include? key camelized_key = key.to_s.downcase.split("_").map(&:capitalize).join("") base_class.const_get(camelized_key) rescue base_class end |
.initialize(key, cs) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/vobject/vcalendar/component.rb', line 17 def initialize(key, cs) # super key, cs self.comp_name = key raise_invalid_initialization if key != name self.children = [] if cs.is_a?(Array) cs.each do |component| c = [] component.each_key do |k| val = component[k] # iteration of array || hash values is making the value a key! next if k.class == Array next if k.class == Hash cc = child_class(k, val) c << cc.new(k, val) end children << c end else cs.each_key do |k| val = cs[k] # iteration of array || hash values is making the value a key! next if k.class == Array next if k.class == Hash cc = child_class(k, val) children << cc.new(k, val) end end end |