Class: Io::Flow::V0::Models::UnitOfTime

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) ⇒ UnitOfTime

Returns a new instance of UnitOfTime.



20132
20133
20134
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20132

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



20130
20131
20132
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20130

def value
  @value
end

Class Method Details

.ALLObject



20152
20153
20154
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20152

def UnitOfTime.ALL
  @@all ||= [UnitOfTime.year, UnitOfTime.month, UnitOfTime.week, UnitOfTime.day, UnitOfTime.hour, UnitOfTime.minute]
end

.apply(value) ⇒ Object

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



20137
20138
20139
20140
20141
20142
20143
20144
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20137

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

.dayObject



20168
20169
20170
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20168

def UnitOfTime.day
  @@_day ||= UnitOfTime.new('day')
end

.from_string(value) ⇒ Object

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



20147
20148
20149
20150
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20147

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

.hourObject



20172
20173
20174
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20172

def UnitOfTime.hour
  @@_hour ||= UnitOfTime.new('hour')
end

.minuteObject



20176
20177
20178
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20176

def UnitOfTime.minute
  @@_minute ||= UnitOfTime.new('minute')
end

.monthObject



20160
20161
20162
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20160

def UnitOfTime.month
  @@_month ||= UnitOfTime.new('month')
end

.weekObject



20164
20165
20166
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20164

def UnitOfTime.week
  @@_week ||= UnitOfTime.new('week')
end

.yearObject



20156
20157
20158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20156

def UnitOfTime.year
  @@_year ||= UnitOfTime.new('year')
end

Instance Method Details

#to_hashObject



20180
20181
20182
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20180

def to_hash
  value
end