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.



16731
16732
16733
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16731

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



16729
16730
16731
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16729

def value
  @value
end

Class Method Details

.ALLObject



16751
16752
16753
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16751

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



16736
16737
16738
16739
16740
16741
16742
16743
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16736

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



16746
16747
16748
16749
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16746

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

.imperialObject



16755
16756
16757
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16755

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

.metricObject



16759
16760
16761
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16759

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

Instance Method Details

#to_hashObject



16763
16764
16765
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16763

def to_hash
  value
end