Class: Io::Flow::V0::Models::Rounding

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 = {}) ⇒ Rounding

Returns a new instance of Rounding.



48608
48609
48610
48611
48612
48613
48614
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48608

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:type, :method, :value], 'Rounding')
  @type = (x = opts.delete(:type); x.is_a?(::Io::Flow::V0::Models::RoundingType) ? x : ::Io::Flow::V0::Models::RoundingType.apply(x))
  @method = (x = opts.delete(:method); x.is_a?(::Io::Flow::V0::Models::RoundingMethod) ? x : ::Io::Flow::V0::Models::RoundingMethod.apply(x))
  @value = HttpClient::Preconditions.assert_class('value', HttpClient::Helper.to_big_decimal(opts.delete(:value)), BigDecimal)
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



48606
48607
48608
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48606

def method
  @method
end

#typeObject (readonly)

Returns the value of attribute type.



48606
48607
48608
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48606

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



48606
48607
48608
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48606

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



48620
48621
48622
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48620

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

#to_hashObject



48624
48625
48626
48627
48628
48629
48630
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48624

def to_hash
  {
    :type => type.value,
    :method => method.value,
    :value => value.to_f.to_s
  }
end

#to_jsonObject



48616
48617
48618
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48616

def to_json
  JSON.dump(to_hash)
end