Class: Camt::Statement
- Inherits:
-
Object
- Object
- Camt::Statement
- Defined in:
- lib/camt/statement.rb
Instance Attribute Summary collapse
-
#country_code ⇒ Object
readonly
Returns the value of attribute country_code.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #created_at ⇒ Object
- #date ⇒ Object
- #electronic_sequence_number ⇒ Object
- #end_balance ⇒ Object
- #id ⇒ Object
-
#initialize(xml_node, country_code) ⇒ Statement
constructor
A new instance of Statement.
- #local_account ⇒ Object (also: #iban)
- #local_currency ⇒ Object
- #start_balance ⇒ Object
- #transactions ⇒ Object
Constructor Details
#initialize(xml_node, country_code) ⇒ Statement
Returns a new instance of Statement.
6 7 8 9 |
# File 'lib/camt/statement.rb', line 6 def initialize(xml_node, country_code) @node = xml_node @country_code = country_code end |
Instance Attribute Details
#country_code ⇒ Object (readonly)
Returns the value of attribute country_code.
4 5 6 |
# File 'lib/camt/statement.rb', line 4 def country_code @country_code end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
4 5 6 |
# File 'lib/camt/statement.rb', line 4 def node @node end |
Instance Method Details
#created_at ⇒ Object
19 20 21 |
# File 'lib/camt/statement.rb', line 19 def created_at @created_at ||= Time.parse(node.at('./CreDtTm').text) end |
#date ⇒ Object
34 35 36 |
# File 'lib/camt/statement.rb', line 34 def date @date ||= Date.parse(node.at('./Ntry[1]/ValDt/Dt | ./Ntry[1]/ValDt/DtTm').text) end |
#electronic_sequence_number ⇒ Object
15 16 17 |
# File 'lib/camt/statement.rb', line 15 def electronic_sequence_number @electronic_sequence_number ||= node.at('./ElctrncSeqNb').text end |
#end_balance ⇒ Object
42 43 44 |
# File 'lib/camt/statement.rb', line 42 def end_balance @end_balance ||= get_end_balance end |
#id ⇒ Object
11 12 13 |
# File 'lib/camt/statement.rb', line 11 def id @id ||= node.at('./Id').text end |
#local_account ⇒ Object Also known as: iban
23 24 25 |
# File 'lib/camt/statement.rb', line 23 def local_account @local_account ||= node.at('./Acct/Id').text.strip end |
#local_currency ⇒ Object
29 30 31 32 |
# File 'lib/camt/statement.rb', line 29 def local_currency @local_currency ||= node.at('./Acct/Ccy').try(:text) || node.at('./Bal/Amt').attribute("Ccy").value end |
#start_balance ⇒ Object
38 39 40 |
# File 'lib/camt/statement.rb', line 38 def start_balance @start_balance ||= get_start_balance end |
#transactions ⇒ Object
46 47 48 |
# File 'lib/camt/statement.rb', line 46 def transactions @transactions ||= node.xpath('./Ntry').map { |node| parse_Ntry(node) } end |