Class: Nordea::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/nordea/transaction.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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,  = nil)
  @date, @amount, @text, @account = date, amount, text, 
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



9
10
11
# File 'lib/nordea/transaction.rb', line 9

def 
  @account
end

#amountObject

Returns the value of attribute amount.



9
10
11
# File 'lib/nordea/transaction.rb', line 9

def amount
  @amount
end

#dateObject

Returns the value of attribute date.



9
10
11
# File 'lib/nordea/transaction.rb', line 9

def date
  @date
end

#textObject

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,  = 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, )
end

Instance Method Details

#deposit?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/nordea/transaction.rb', line 19

def deposit?
  amount > 0
end

#final_textObject



11
12
13
# File 'lib/nordea/transaction.rb', line 11

def final_text
  text.sub("Res. köp", "Kortköp")
end

#withdrawal?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/nordea/transaction.rb', line 15

def withdrawal?
  amount < 0
end