Class: Io::Flow::V0::Models::UnitOfMeasurement

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) ⇒ 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

#valueObject (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

.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

.centimeterObject

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_inchObject

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_meterObject

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

.footObject

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

.gramObject

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

.inchObject

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

.kilogramObject

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

.meterObject

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

.millimeterObject

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

.ounceObject

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

.poundObject

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_hashObject



28169
28170
28171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28169

def to_hash
  value
end