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.
12014 12015 12016 12017 12018 12019 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12014 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.
12012 12013 12014 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12012 def unit @unit end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
12012 12013 12014 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12012 def value @value end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
12025 12026 12027 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12025 def copy(incoming={}) Duration.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
12029 12030 12031 12032 12033 12034 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12029 def to_hash { :unit => unit.value, :value => value } end |
#to_json ⇒ Object
12021 12022 12023 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12021 def to_json JSON.dump(to_hash) end |