Class: Io::Flow::V0::Models::MeasurementSystem

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

Returns a new instance of MeasurementSystem.



11192
11193
11194
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11192

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



11190
11191
11192
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11190

def value
  @value
end

Class Method Details

.ALLObject



11212
11213
11214
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11212

def MeasurementSystem.ALL
  @@all ||= [MeasurementSystem.imperial, MeasurementSystem.metric]
end

.apply(value) ⇒ Object

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



11197
11198
11199
11200
11201
11202
11203
11204
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11197

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

.from_string(value) ⇒ Object

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



11207
11208
11209
11210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11207

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

.imperialObject



11216
11217
11218
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11216

def MeasurementSystem.imperial
  @@_imperial ||= MeasurementSystem.new('imperial')
end

.metricObject



11220
11221
11222
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11220

def MeasurementSystem.metric
  @@_metric ||= MeasurementSystem.new('metric')
end

Instance Method Details

#to_hashObject



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

def to_hash
  value
end