Class: Io::Flow::V0::Models::Measurement
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Measurement
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#units ⇒ Object
readonly
Returns the value of attribute units.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Measurement
constructor
A new instance of Measurement.
- #to_hash ⇒ Object
- #to_json ⇒ Object
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
#units ⇒ Object (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 |
#value ⇒ Object (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_hash ⇒ Object
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_json ⇒ Object
27042 27043 27044 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27042 def to_json JSON.dump(to_hash) end |