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.



21207
21208
21209
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21207

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



21205
21206
21207
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21205

def value
  @value
end

Class Method Details

.ALLObject



21227
21228
21229
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21227

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



21212
21213
21214
21215
21216
21217
21218
21219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21212

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



21243
21244
21245
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21243

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



21222
21223
21224
21225
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21222

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

.hourObject



21247
21248
21249
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21247

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

.minuteObject



21251
21252
21253
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21251

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

.monthObject



21235
21236
21237
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21235

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

.weekObject



21239
21240
21241
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21239

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

.yearObject



21231
21232
21233
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21231

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

Instance Method Details

#to_hashObject



21255
21256
21257
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21255

def to_hash
  value
end