Class: Nylas::When

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Model::Attributable
Defined in:
lib/nylas/when.rb

Overview

Structure to represent all the Nylas time types.

Instance Method Summary collapse

Methods included from Model::Attributable

#attributes, included, #initialize, #to_h

Instance Method Details

#as_timespanObject



36
37
38
39
40
# File 'lib/nylas/when.rb', line 36

def as_timespan
  return unless object == "timespan"

  Timespan.new(object: object, start_time: start_time, end_time: end_time)
end

#rangeObject



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/nylas/when.rb', line 42

def range
  case object
  when "timespan"
    Range.new(start_time, end_time)
  when "datespan"
    Range.new(start_date, end_date)
  when "date"
    Range.new(date, date)
  when "time"
    Range.new(time, time)
  end
end

#valid?Boolean

Validates the When object

Returns:

  • (Boolean)

    True if the When is valid

Raises:

  • (ArgumentError)

    If any of the timezone fields are not valid IANA database names



58
59
60
61
62
63
64
# File 'lib/nylas/when.rb', line 58

def valid?
  validate_timezone(timezone) if timezone
  validate_timezone(start_timezone) if start_timezone
  validate_timezone(end_timezone) if end_timezone

  true
end