Class: Io::Flow::V0::Models::MeasurementSystem
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::MeasurementSystem
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
- .ALL ⇒ Object
-
.apply(value) ⇒ Object
Returns the instance of MeasurementSystem for this value, creating a new instance for an unknown value.
-
.from_string(value) ⇒ Object
Returns the instance of MeasurementSystem for this value, or nil if not found.
- .imperial ⇒ Object
- .metric ⇒ Object
Instance Method Summary collapse
-
#initialize(value) ⇒ MeasurementSystem
constructor
A new instance of MeasurementSystem.
- #to_hash ⇒ Object
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
#value ⇒ Object (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
.ALL ⇒ Object
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 |
.imperial ⇒ Object
11216 11217 11218 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11216 def MeasurementSystem.imperial @@_imperial ||= MeasurementSystem.new('imperial') end |
.metric ⇒ Object
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_hash ⇒ Object
11224 11225 11226 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11224 def to_hash value end |