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.



16926
16927
16928
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16926

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



16924
16925
16926
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16924

def value
  @value
end

Class Method Details

.ALLObject



16946
16947
16948
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16946

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



16931
16932
16933
16934
16935
16936
16937
16938
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16931

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



16941
16942
16943
16944
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16941

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

.imperialObject



16950
16951
16952
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16950

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

.metricObject



16954
16955
16956
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16954

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

Instance Method Details

#to_hashObject



16958
16959
16960
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16958

def to_hash
  value
end