Class: CalendarApi::EventType

Inherits:
Object
  • Object
show all
Defined in:
lib/calendar_api/models/event_type.rb

Overview

The specific type of event.

Constant Summary collapse

EVENT_TYPE =
[
  # TODO: Write general description for BIRTHDAY
  BIRTHDAY = 'birthday'.freeze,

  # TODO: Write general description for DEFAULT
  DEFAULT = 'default'.freeze,

  # TODO: Write general description for FOCUSTIME
  FOCUSTIME = 'focusTime'.freeze,

  # TODO: Write general description for FROMGMAIL
  FROMGMAIL = 'fromGmail'.freeze,

  # TODO: Write general description for OUTOFOFFICE
  OUTOFOFFICE = 'outOfOffice'.freeze,

  # TODO: Write general description for WORKINGLOCATION
  WORKINGLOCATION = 'workingLocation'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = BIRTHDAY) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/calendar_api/models/event_type.rb', line 35

def self.from_value(value, default_value = BIRTHDAY)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'birthday' then BIRTHDAY
  when 'default' then DEFAULT
  when 'focustime' then FOCUSTIME
  when 'fromgmail' then FROMGMAIL
  when 'outofoffice' then OUTOFOFFICE
  when 'workinglocation' then WORKINGLOCATION
  else
    default_value
  end
end

.validate(value) ⇒ Object



29
30
31
32
33
# File 'lib/calendar_api/models/event_type.rb', line 29

def self.validate(value)
  return false if value.nil?

  EVENT_TYPE.include?(value)
end