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.



15292
15293
15294
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15292

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



15290
15291
15292
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15290

def value
  @value
end

Class Method Details

.ALLObject



15312
15313
15314
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15312

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



15297
15298
15299
15300
15301
15302
15303
15304
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15297

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



15328
15329
15330
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15328

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



15307
15308
15309
15310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15307

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

.hourObject



15332
15333
15334
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15332

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

.minuteObject



15336
15337
15338
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15336

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

.monthObject



15320
15321
15322
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15320

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

.weekObject



15324
15325
15326
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15324

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

.yearObject



15316
15317
15318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15316

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

Instance Method Details

#to_hashObject



15340
15341
15342
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15340

def to_hash
  value
end