Class: Io::Flow::V0::Models::SyncDuration

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

Overview

Represents a duration of time with the ability to convert to a scala FiniteDuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ SyncDuration

Returns a new instance of SyncDuration.



53211
53212
53213
53214
53215
53216
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53211

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

Instance Attribute Details

#unitObject (readonly)

Returns the value of attribute unit.



53209
53210
53211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53209

def unit
  @unit
end

#valueObject (readonly)

Returns the value of attribute value.



53209
53210
53211
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53209

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



53222
53223
53224
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53222

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

#to_hashObject



53226
53227
53228
53229
53230
53231
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53226

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

#to_jsonObject



53218
53219
53220
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53218

def to_json
  JSON.dump(to_hash)
end