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.



9195
9196
9197
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9195

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



9193
9194
9195
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9193

def value
  @value
end

Class Method Details

.ALLObject



9215
9216
9217
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9215

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



9200
9201
9202
9203
9204
9205
9206
9207
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9200

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



9210
9211
9212
9213
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9210

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

.imperialObject



9219
9220
9221
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9219

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

.metricObject



9223
9224
9225
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9223

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

Instance Method Details

#to_hashObject



9227
9228
9229
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9227

def to_hash
  value
end