Class: Pagseguro::Charge::Amount
- Inherits:
-
Object
- Object
- Pagseguro::Charge::Amount
- Defined in:
- lib/pagseguro/charge/amount.rb
Overview
Credit card data
Instance Attribute Summary collapse
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(args = {}) ⇒ Amount
constructor
A new instance of Amount.
- #to_json(*options) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Amount
Returns a new instance of Amount.
10 11 12 13 14 |
# File 'lib/pagseguro/charge/amount.rb', line 10 def initialize(args = {}) @value = args[:value] @currency = args[:currency] @summary = args[:summary] end |
Instance Attribute Details
#currency ⇒ Object
Returns the value of attribute currency.
6 7 8 |
# File 'lib/pagseguro/charge/amount.rb', line 6 def currency @currency end |
#summary ⇒ Object
Returns the value of attribute summary.
6 7 8 |
# File 'lib/pagseguro/charge/amount.rb', line 6 def summary @summary end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/pagseguro/charge/amount.rb', line 6 def value @value end |
Class Method Details
.fill_from_json(data) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pagseguro/charge/amount.rb', line 22 def self.fill_from_json(data) return if data.nil? amount = new amount.currency = data["currency"] amount.value = data["value"] amount.summary = Summary.fill_from_json(data["summary"]) amount end |
Instance Method Details
#as_json(options = {}) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/pagseguro/charge/amount.rb', line 33 def as_json(={}) { value: @value, currency: @currency, summary: @summary } end |
#to_json(*options) ⇒ Object
16 17 18 19 20 |
# File 'lib/pagseguro/charge/amount.rb', line 16 def to_json(*) hash = as_json(*) hash.reject! {|k,v| v.nil?} hash.to_json(*) end |