Class: Camt::Transaction
- Inherits:
-
Object
- Object
- Camt::Transaction
- Defined in:
- lib/camt/transaction.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
- #effective_date ⇒ Object
- #execution_date ⇒ Object
-
#initialize(xml_node, country_code) ⇒ Transaction
constructor
A new instance of Transaction.
- #purpose ⇒ Object
- #transaction_details ⇒ Object (also: #details)
- #transfer_type ⇒ Object (also: #type)
- #transferred_amount ⇒ Object (also: #amount)
Constructor Details
#initialize(xml_node, country_code) ⇒ Transaction
Returns a new instance of Transaction.
6 7 8 9 |
# File 'lib/camt/transaction.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/transaction.rb', line 4 def country_code @country_code end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
4 5 6 |
# File 'lib/camt/transaction.rb', line 4 def node @node end |
Instance Method Details
#effective_date ⇒ Object
15 16 17 |
# File 'lib/camt/transaction.rb', line 15 def effective_date @effective_date ||= Date.parse(node.at('./ValDt/Dt | ./ValDt/DtTm').text) end |
#execution_date ⇒ Object
11 12 13 |
# File 'lib/camt/transaction.rb', line 11 def execution_date @execution_date ||= Date.parse(node.at('./BookgDt/Dt | ./BookgDt/DtTm').text) end |
#purpose ⇒ Object
37 38 39 40 |
# File 'lib/camt/transaction.rb', line 37 def purpose @purpose ||= node.at('./AddtlNtryInf').try(:text) || details.map { |detail| detail[:references] }.flatten.join(" ") end |
#transaction_details ⇒ Object Also known as: details
31 32 33 |
# File 'lib/camt/transaction.rb', line 31 def transaction_details @transaction_details ||= node.xpath('.//NtryDtls//TxDtls').map { |node| parse_TxDtls(node) } end |
#transfer_type ⇒ Object Also known as: type
19 20 21 |
# File 'lib/camt/transaction.rb', line 19 def transfer_type @transfer_type ||= get_transfer_type(node.at('./BkTxCd/Prtry')) end |