Class: CalendarApi::EventTransparency

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

Overview

Whether the event blocks time on the calendar. “opaque” means the event does block time; “transparent” means it does not.

Constant Summary collapse

EVENT_TRANSPARENCY =
[
  # TODO: Write general description for OPAQUE
  OPAQUE = 'opaque'.freeze,

  # TODO: Write general description for TRANSPARENT
  TRANSPARENT = 'transparent'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = OPAQUE) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/calendar_api/models/event_transparency.rb', line 24

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

  str = value.to_s.strip

  case str.downcase
  when 'opaque' then OPAQUE
  when 'transparent' then TRANSPARENT
  else
    default_value
  end
end

.validate(value) ⇒ Object



18
19
20
21
22
# File 'lib/calendar_api/models/event_transparency.rb', line 18

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

  EVENT_TRANSPARENCY.include?(value)
end