Class: Icalendar::Component
- Inherits:
-
Object
- Object
- Icalendar::Component
- Includes:
- HasComponents, HasProperties
- Defined in:
- lib/icalendar/component.rb
Direct Known Subclasses
Alarm, Calendar, Event, Freebusy, Journal, Timezone, Timezone::Daylight, Timezone::Standard, Todo
Constant Summary
Constants included from HasComponents
HasComponents::METHOD_MISSING_ADD_REGEX, HasComponents::METHOD_MISSING_X_FLAG_REGEX
Instance Attribute Summary collapse
-
#ical_name ⇒ Object
readonly
Returns the value of attribute ical_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, ical_name = nil) ⇒ Component
constructor
A new instance of Component.
- #new_uid ⇒ Object
- #to_ical ⇒ Object
Methods included from HasComponents
#add_component, #add_custom_component, #custom_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.
22 23 24 25 26 |
# File 'lib/icalendar/component.rb', line 22 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_name ⇒ Object (readonly)
Returns the value of attribute ical_name.
12 13 14 |
# File 'lib/icalendar/component.rb', line 12 def ical_name @ical_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/icalendar/component.rb', line 11 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
13 14 15 |
# File 'lib/icalendar/component.rb', line 13 def parent @parent end |
Class Method Details
.parse(source) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/icalendar/component.rb', line 15 def self.parse(source) _parse source rescue ArgumentError source.rewind if source.respond_to?(:rewind) _parse Parser.clean_bad_wrapping(source) end |
Instance Method Details
#new_uid ⇒ Object
28 29 30 |
# File 'lib/icalendar/component.rb', line 28 def new_uid SecureRandom.uuid end |
#to_ical ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/icalendar/component.rb', line 32 def to_ical [ "BEGIN:#{ical_name}", ical_properties, ical_components, "END:#{ical_name}\r\n" ].compact.join "\r\n" end |