Class: Io::Flow::V0::Models::UnitOfMeasurement
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::UnitOfMeasurement
- 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 UnitOfMeasurement for this value, creating a new instance for an unknown value.
-
.centimeter ⇒ Object
Equivalent to CENTI(METRE).
-
.cubic_inch ⇒ Object
A unit of volume equal to one cubic inch (in³).
-
.cubic_meter ⇒ Object
The metric unit for volume quantities (m³).
-
.foot ⇒ Object
A unit of length equal to 0.3048 m (standard name ft).
-
.from_string(value) ⇒ Object
Returns the instance of UnitOfMeasurement for this value, or nil if not found.
-
.gram ⇒ Object
A unit of mass equal to 1 / 1000 kilogram (standard name g).
-
.inch ⇒ Object
A unit of length equal to 0.0254 m (standard name in).
-
.kilogram ⇒ Object
The base unit for mass quantities (kg).
-
.meter ⇒ Object
The base unit for length quantities (m).
-
.millimeter ⇒ Object
Equivalent to MILLI(METRE).
-
.ounce ⇒ Object
A unit of mass equal to 1 / 16 POUND (standard name oz).
-
.pound ⇒ Object
A unit of mass equal to 453.59237 grams (avoirdupois pound, standard name lb).
Instance Method Summary collapse
-
#initialize(value) ⇒ UnitOfMeasurement
constructor
A new instance of UnitOfMeasurement.
- #to_hash ⇒ Object
Constructor Details
#initialize(value) ⇒ UnitOfMeasurement
Returns a new instance of UnitOfMeasurement.
28090 28091 28092 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28090 def initialize(value) @value = HttpClient::Preconditions.assert_class('value', value, String) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
28088 28089 28090 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28088 def value @value end |
Class Method Details
.ALL ⇒ Object
28110 28111 28112 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28110 def UnitOfMeasurement.ALL @@all ||= [UnitOfMeasurement.millimeter, UnitOfMeasurement.centimeter, UnitOfMeasurement.inch, UnitOfMeasurement.foot, UnitOfMeasurement.cubic_inch, UnitOfMeasurement.cubic_meter, UnitOfMeasurement.gram, UnitOfMeasurement.kilogram, UnitOfMeasurement.meter, UnitOfMeasurement.ounce, UnitOfMeasurement.pound] end |
.apply(value) ⇒ Object
Returns the instance of UnitOfMeasurement for this value, creating a new instance for an unknown value
28095 28096 28097 28098 28099 28100 28101 28102 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28095 def UnitOfMeasurement.apply(value) if value.instance_of?(UnitOfMeasurement) value else HttpClient::Preconditions.assert_class_or_nil('value', value, String) value.nil? ? nil : (from_string(value) || UnitOfMeasurement.new(value)) end end |
.centimeter ⇒ Object
Equivalent to CENTI(METRE).
28120 28121 28122 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28120 def UnitOfMeasurement.centimeter @@_centimeter ||= UnitOfMeasurement.new('centimeter') end |
.cubic_inch ⇒ Object
A unit of volume equal to one cubic inch (in³).
28135 28136 28137 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28135 def UnitOfMeasurement.cubic_inch @@_cubic_inch ||= UnitOfMeasurement.new('cubic_inch') end |
.cubic_meter ⇒ Object
The metric unit for volume quantities (m³).
28140 28141 28142 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28140 def UnitOfMeasurement.cubic_meter @@_cubic_meter ||= UnitOfMeasurement.new('cubic_meter') end |
.foot ⇒ Object
A unit of length equal to 0.3048 m (standard name ft).
28130 28131 28132 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28130 def UnitOfMeasurement.foot @@_foot ||= UnitOfMeasurement.new('foot') end |
.from_string(value) ⇒ Object
Returns the instance of UnitOfMeasurement for this value, or nil if not found
28105 28106 28107 28108 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28105 def UnitOfMeasurement.from_string(value) HttpClient::Preconditions.assert_class('value', value, String) UnitOfMeasurement.ALL.find { |v| v.value == value } end |
.gram ⇒ Object
A unit of mass equal to 1 / 1000 kilogram (standard name g).
28145 28146 28147 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28145 def UnitOfMeasurement.gram @@_gram ||= UnitOfMeasurement.new('gram') end |
.inch ⇒ Object
A unit of length equal to 0.0254 m (standard name in).
28125 28126 28127 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28125 def UnitOfMeasurement.inch @@_inch ||= UnitOfMeasurement.new('inch') end |
.kilogram ⇒ Object
The base unit for mass quantities (kg).
28150 28151 28152 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28150 def UnitOfMeasurement.kilogram @@_kilogram ||= UnitOfMeasurement.new('kilogram') end |
.meter ⇒ Object
The base unit for length quantities (m).
28155 28156 28157 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28155 def UnitOfMeasurement.meter @@_meter ||= UnitOfMeasurement.new('meter') end |
.millimeter ⇒ Object
Equivalent to MILLI(METRE).
28115 28116 28117 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28115 def UnitOfMeasurement.millimeter @@_millimeter ||= UnitOfMeasurement.new('millimeter') end |
.ounce ⇒ Object
A unit of mass equal to 1 / 16 POUND (standard name oz).
28160 28161 28162 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28160 def UnitOfMeasurement.ounce @@_ounce ||= UnitOfMeasurement.new('ounce') end |
.pound ⇒ Object
A unit of mass equal to 453.59237 grams (avoirdupois pound, standard name lb).
28165 28166 28167 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28165 def UnitOfMeasurement.pound @@_pound ||= UnitOfMeasurement.new('pound') end |
Instance Method Details
#to_hash ⇒ Object
28169 28170 28171 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28169 def to_hash value end |