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.



11224
11225
11226
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11224

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



11222
11223
11224
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11222

def value
  @value
end

Class Method Details

.ALLObject



11244
11245
11246
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11244

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



11229
11230
11231
11232
11233
11234
11235
11236
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11229

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



11260
11261
11262
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11260

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



11239
11240
11241
11242
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11239

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

.hourObject



11264
11265
11266
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11264

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

.minuteObject



11268
11269
11270
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11268

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

.monthObject



11252
11253
11254
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11252

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

.weekObject



11256
11257
11258
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11256

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

.yearObject



11248
11249
11250
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11248

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

Instance Method Details

#to_hashObject



11272
11273
11274
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11272

def to_hash
  value
end