Class: Io::Flow::V0::Models::Measurement

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Measurement

Returns a new instance of Measurement.



27035
27036
27037
27038
27039
27040
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27035

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:value, :units], 'Measurement')
  @value = HttpClient::Preconditions.assert_class('value', opts.delete(:value), String)
  @units = (x = opts.delete(:units); x.is_a?(::Io::Flow::V0::Models::UnitOfMeasurement) ? x : ::Io::Flow::V0::Models::UnitOfMeasurement.apply(x))
end

Instance Attribute Details

#unitsObject (readonly)

Returns the value of attribute units.



27033
27034
27035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27033

def units
  @units
end

#valueObject (readonly)

Returns the value of attribute value.



27033
27034
27035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27033

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



27046
27047
27048
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27046

def copy(incoming={})
  Measurement.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



27050
27051
27052
27053
27054
27055
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27050

def to_hash
  {
    :value => value,
    :units => units.value
  }
end

#to_jsonObject



27042
27043
27044
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27042

def to_json
  JSON.dump(to_hash)
end