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.



17409
17410
17411
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17409

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



17407
17408
17409
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17407

def value
  @value
end

Class Method Details

.ALLObject



17429
17430
17431
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17429

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



17414
17415
17416
17417
17418
17419
17420
17421
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17414

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



17424
17425
17426
17427
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17424

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

.imperialObject



17433
17434
17435
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17433

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

.metricObject



17437
17438
17439
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17437

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

Instance Method Details

#to_hashObject



17441
17442
17443
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17441

def to_hash
  value
end