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.



12980
12981
12982
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12980

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



12978
12979
12980
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12978

def value
  @value
end

Class Method Details

.ALLObject



13000
13001
13002
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13000

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



12985
12986
12987
12988
12989
12990
12991
12992
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12985

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



12995
12996
12997
12998
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12995

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

.imperialObject



13004
13005
13006
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13004

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

.metricObject



13008
13009
13010
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13008

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

Instance Method Details

#to_hashObject



13012
13013
13014
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13012

def to_hash
  value
end