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.



13223
13224
13225
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13223

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



13221
13222
13223
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13221

def value
  @value
end

Class Method Details

.ALLObject



13243
13244
13245
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13243

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



13228
13229
13230
13231
13232
13233
13234
13235
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13228

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



13259
13260
13261
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13259

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



13238
13239
13240
13241
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13238

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

.hourObject



13263
13264
13265
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13263

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

.minuteObject



13267
13268
13269
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13267

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

.monthObject



13251
13252
13253
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13251

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

.weekObject



13255
13256
13257
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13255

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

.yearObject



13247
13248
13249
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13247

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

Instance Method Details

#to_hashObject



13271
13272
13273
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13271

def to_hash
  value
end