Class: Icalendar::Alarm

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

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.



23
24
25
# File 'lib/icalendar/alarm.rb', line 23

def initialize
  super 'alarm'
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)


27
28
29
30
31
32
33
34
35
36
37
# File 'lib/icalendar/alarm.rb', line 27

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