Class: Io::Flow::V0::Models::Calendar

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Calendar

Returns a new instance of Calendar.



11999
12000
12001
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11999

def initialize(value)
  @value = HttpClient::Preconditions.assert_class('value', value, String)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



11997
11998
11999
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11997

def value
  @value
end

Class Method Details

.ALLObject



12019
12020
12021
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12019

def Calendar.ALL
  @@all ||= [Calendar.weekdays, Calendar.everyday]
end

.apply(value) ⇒ Object

Returns the instance of Calendar for this value, creating a new instance for an unknown value



12004
12005
12006
12007
12008
12009
12010
12011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12004

def Calendar.apply(value)
  if value.instance_of?(Calendar)
    value
  else
    HttpClient::Preconditions.assert_class_or_nil('value', value, String)
    value.nil? ? nil : (from_string(value) || Calendar.new(value))
  end
end

.everydayObject

7 days per week



12029
12030
12031
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12029

def Calendar.everyday
  @@_everyday ||= Calendar.new('everyday')
end

.from_string(value) ⇒ Object

Returns the instance of Calendar for this value, or nil if not found



12014
12015
12016
12017
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12014

def Calendar.from_string(value)
  HttpClient::Preconditions.assert_class('value', value, String)
  Calendar.ALL.find { |v| v.value == value }
end

.weekdaysObject

Mon - Fri



12024
12025
12026
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12024

def Calendar.weekdays
  @@_weekdays ||= Calendar.new('weekdays')
end

Instance Method Details

#to_hashObject



12033
12034
12035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12033

def to_hash
  value
end