Class: Io::Flow::V0::Models::Duration
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Duration
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Represents a duration of time.
Instance Attribute Summary collapse
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Duration
constructor
A new instance of Duration.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Duration
Returns a new instance of Duration.
30832 30833 30834 30835 30836 30837 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30832 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:unit, :value], 'Duration') @unit = (x = opts.delete(:unit); x.is_a?(::Io::Flow::V0::Models::UnitOfTime) ? x : ::Io::Flow::V0::Models::UnitOfTime.apply(x)) @value = HttpClient::Preconditions.assert_class('value', opts.delete(:value), Integer) end |
Instance Attribute Details
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
30830 30831 30832 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30830 def unit @unit end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
30830 30831 30832 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30830 def value @value end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
30843 30844 30845 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30843 def copy(incoming={}) Duration.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
30847 30848 30849 30850 30851 30852 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30847 def to_hash { :unit => unit.value, :value => value } end |
#to_json ⇒ Object
30839 30840 30841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30839 def to_json JSON.dump(to_hash) end |