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.



8502
8503
8504
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8502

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



8500
8501
8502
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8500

def value
  @value
end

Class Method Details

.ALLObject



8522
8523
8524
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8522

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



8507
8508
8509
8510
8511
8512
8513
8514
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8507

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



8517
8518
8519
8520
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8517

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

.imperialObject



8526
8527
8528
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8526

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

.metricObject



8530
8531
8532
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8530

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

Instance Method Details

#to_hashObject



8534
8535
8536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8534

def to_hash
  value
end