Class: BudaApi::Models::Amount
- Defined in:
- lib/buda_api/models.rb
Overview
Amount model for currency amounts
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(data) ⇒ Amount
constructor
A new instance of Amount.
- #to_s ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(data) ⇒ Amount
Returns a new instance of Amount.
50 51 52 53 54 |
# File 'lib/buda_api/models.rb', line 50 def initialize(data) super(data) @amount = data["amount"]&.to_f || 0.0 @currency = data["currency"] end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
56 57 58 |
# File 'lib/buda_api/models.rb', line 56 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
56 57 58 |
# File 'lib/buda_api/models.rb', line 56 def currency @currency end |
Instance Method Details
#==(other) ⇒ Object
62 63 64 65 66 |
# File 'lib/buda_api/models.rb', line 62 def ==(other) other.is_a?(Amount) && @amount == other.amount && @currency == other.currency end |
#to_s ⇒ Object
58 59 60 |
# File 'lib/buda_api/models.rb', line 58 def to_s "#{@amount} #{@currency}" end |