Class: Nordea::Transaction
- Inherits:
-
Object
- Object
- Nordea::Transaction
- Defined in:
- lib/nordea/transaction.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#date ⇒ Object
Returns the value of attribute date.
-
#text ⇒ Object
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #deposit? ⇒ Boolean
- #final_text ⇒ Object
-
#initialize(date, amount, text, account = nil) ⇒ Transaction
constructor
A new instance of Transaction.
- #withdrawal? ⇒ Boolean
Constructor Details
#initialize(date, amount, text, account = nil) ⇒ Transaction
Returns a new instance of Transaction.
5 6 7 |
# File 'lib/nordea/transaction.rb', line 5 def initialize(date, amount, text, account = nil) @date, @amount, @text, @account = date, amount, text, account end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
9 10 11 |
# File 'lib/nordea/transaction.rb', line 9 def account @account end |
#amount ⇒ Object
Returns the value of attribute amount.
9 10 11 |
# File 'lib/nordea/transaction.rb', line 9 def amount @amount end |
#date ⇒ Object
Returns the value of attribute date.
9 10 11 |
# File 'lib/nordea/transaction.rb', line 9 def date @date end |
#text ⇒ Object
Returns the value of attribute text.
9 10 11 |
# File 'lib/nordea/transaction.rb', line 9 def text @text end |
Class Method Details
.new_from_xml(xml, account = nil) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/nordea/transaction.rb', line 23 def self.new_from_xml(xml, account = nil) node = xml.is_a?(String) ? Hpricot.XML(xml) : xml date = Date.parse(node.at("setvar[@name='date']")['value']) amount = Support.dirty_currency_string_to_f(node.at("setvar[@name='amount']")['value']) text = node.at("setvar[@name='text']")['value'] new(date, amount, text, account) end |
Instance Method Details
#deposit? ⇒ Boolean
19 20 21 |
# File 'lib/nordea/transaction.rb', line 19 def deposit? amount > 0 end |
#final_text ⇒ Object
11 12 13 |
# File 'lib/nordea/transaction.rb', line 11 def final_text text.sub("Res. köp", "Kortköp") end |
#withdrawal? ⇒ Boolean
15 16 17 |
# File 'lib/nordea/transaction.rb', line 15 def withdrawal? amount < 0 end |