class Icalendar::Values::DateOrDateTime

DateOrDateTime can be used to set an attribute to either a Date or a DateTime value. It should not be used wihtout also invoking the `call` method.

Attributes

params[R]
parsed[R]
value[R]

Public Class Methods

new(value, params = {}) click to toggle source
# File lib/icalendar/values/date_or_date_time.rb, line 9
def initialize(value, params = {})
  @value = value
  @params = params
end

Public Instance Methods

call() click to toggle source
# File lib/icalendar/values/date_or_date_time.rb, line 14
def call
  @parsed ||= begin
                Icalendar::Values::DateTime.new value, params
              rescue Icalendar::Values::DateTime::FormatError
                Icalendar::Values::Date.new value, params
              end
end
to_ical() click to toggle source
# File lib/icalendar/values/date_or_date_time.rb, line 22
def to_ical
  fail NoMethodError, 'You cannot use DateOrDateTime directly. Invoke `call` before `to_ical`'
end