Class: Simplepay::Support::Amount

Inherits:
Object
  • Object
show all
Defined in:
lib/simplepay/support/amount.rb

Overview

Amazon often represents dollar values as a combination of a value and a currency. In several types of requests, the combination is required for communication.

At the present time, Amazon only uses USD.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount, currency = Simplepay::Currency::USD) ⇒ Amount

Returns a new instance of Amount.



18
19
20
21
# File 'lib/simplepay/support/amount.rb', line 18

def initialize(amount, currency = Simplepay::Currency::USD)
  self.amount   = amount
  self.currency = currency
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



15
16
17
# File 'lib/simplepay/support/amount.rb', line 15

def amount
  @amount
end

#currencyObject

Returns the value of attribute currency.



16
17
18
# File 'lib/simplepay/support/amount.rb', line 16

def currency
  @currency
end

Instance Method Details

#to_sObject



48
49
50
# File 'lib/simplepay/support/amount.rb', line 48

def to_s
  "#{currency.code} #{currency.format % amount}"
end