Class: Icalendar::Alarm

Inherits:
Component show all
Defined in:
lib/icalendar/alarm.rb

Constant Summary

Constants included from HasComponents

HasComponents::METHOD_MISSING_ADD_REGEX, HasComponents::METHOD_MISSING_X_FLAG_REGEX

Instance Attribute Summary

Attributes inherited from Component

#ical_name, #name, #parent

Instance Method Summary collapse

Methods inherited from Component

#new_uid, parse, #to_ical

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?

Constructor Details

#initializeAlarm

Returns a new instance of Alarm.



25
26
27
28
# File 'lib/icalendar/alarm.rb', line 25

def initialize
  super 'alarm'
  self.action = 'DISPLAY'
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Icalendar::HasComponents

Instance Method Details

#valid?(strict = false) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
38
39
40
# File 'lib/icalendar/alarm.rb', line 30

def valid?(strict = false)
  if strict
    # must be part of event or todo
    !(parent.nil? || parent.name == 'event' || parent.name == 'todo') and return false
  end
  # either both duration and repeat or neither should be set
  [duration, repeat].compact.size == 1 and return false
  # attach must be single for audio actions
  action.downcase == 'audio' && attach.compact.size > 1 and return false
  super
end