class Simplepay::Support::SimpleAmount
In new Amazon API requests the amount does not include the currency, SimpleAmount
is used for this, for now.
At the present time, Amazon only uses USD.
Attributes
amount[R]
Public Class Methods
new(amount)
click to toggle source
# File lib/simplepay/support/simple_amount.rb, line 15 def initialize(amount) self.amount = amount end
Public Instance Methods
amount=(amount)
click to toggle source
Sets the amount of the currency value, such as “1” for 1 USD. This amount cannot be negative.
# File lib/simplepay/support/simple_amount.rb, line 24 def amount=(amount) raise(ArgumentError, "Amount cannot be nil") unless amount raise(ArgumentError, "Amount cannot be negative") if amount < 0 @amount = BigDecimal.new(amount.to_s) end
to_s()
click to toggle source
# File lib/simplepay/support/simple_amount.rb, line 30 def to_s "#{'%0.2f' % amount}" end