Class: Icalendar2::Event
- Inherits:
-
Component::Base
- Object
- Component::Base
- Icalendar2::Event
- Defined in:
- lib/icalendar2/component/event.rb
Overview
Constant Summary collapse
- VALUE =
"VEVENT"
Instance Method Summary collapse
-
#alarm(&block) ⇒ Object
Add a new alarm(s) in a block.
- #alarms ⇒ Object
-
#initialize ⇒ Event
constructor
A new instance of Event.
- #to_ical ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from Component::Base
accepts, #add_component, #new_timestamp, #new_uid, requires, #set_property
Constructor Details
#initialize ⇒ Event
Returns a new instance of Event.
13 14 15 16 17 |
# File 'lib/icalendar2/component/event.rb', line 13 def initialize super self.uid = new_uid self.dtstamp = end |
Instance Method Details
#alarm(&block) ⇒ Object
Add a new alarm(s) in a block
20 21 22 23 24 25 26 |
# File 'lib/icalendar2/component/event.rb', line 20 def alarm(&block) a = Alarm.new self.add_component a a.instance_eval(&block) a end |
#alarms ⇒ Object
28 29 30 |
# File 'lib/icalendar2/component/event.rb', line 28 def alarms @components[:alarms] end |
#to_ical ⇒ Object
32 33 34 35 36 37 |
# File 'lib/icalendar2/component/event.rb', line 32 def to_ical str = "#{Tokens::COMPONENT_BEGIN}:#{VALUE}#{Tokens::CRLF}" str << properties_to_ical str << alarm_to_ical str << "#{Tokens::COMPONENT_END}:#{VALUE}#{Tokens::CRLF}" end |
#valid? ⇒ Boolean
39 40 41 |
# File 'lib/icalendar2/component/event.rb', line 39 def valid? alarms ? alarms.all?(&:valid?) : true end |