Class: Icalendar2::Event

Inherits:
Component::Base show all
Defined in:
lib/icalendar2/component/event.rb

Overview

Constant Summary collapse

VALUE =
"VEVENT"

Instance Method Summary collapse

Methods inherited from Component::Base

accepts, #add_component, #new_timestamp, #new_uid, requires, #set_property

Constructor Details

#initializeEvent

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 = new_timestamp
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

#alarmsObject



28
29
30
# File 'lib/icalendar2/component/event.rb', line 28

def alarms
  @components[:alarms]
end

#to_icalObject



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

Returns:

  • (Boolean)


39
40
41
# File 'lib/icalendar2/component/event.rb', line 39

def valid?
  alarms ? alarms.all?(&:valid?) : true
end