Class: SepaFileParser::Record
- Inherits:
-
Object
- Object
- SepaFileParser::Record
- Defined in:
- lib/sepa_file_parser/general/record.rb
Instance Attribute Summary collapse
-
#xml_data ⇒ Object
readonly
Returns the value of attribute xml_data.
Instance Method Summary collapse
- #amount ⇒ Object
- #amount_in_cents ⇒ Object
- #charges_included? ⇒ Boolean
- #credit? ⇒ Boolean
- #currency ⇒ Object
- #debit ⇒ Object
- #debit? ⇒ Boolean
-
#initialize(xml_data) ⇒ Record
constructor
A new instance of Record.
- #sign ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(xml_data) ⇒ Record
Returns a new instance of Record.
8 9 10 11 |
# File 'lib/sepa_file_parser/general/record.rb', line 8 def initialize(xml_data) @xml_data = xml_data @amount = xml_data.xpath('Amt/text()').text end |
Instance Attribute Details
#xml_data ⇒ Object (readonly)
Returns the value of attribute xml_data.
6 7 8 |
# File 'lib/sepa_file_parser/general/record.rb', line 6 def xml_data @xml_data end |
Instance Method Details
#amount ⇒ Object
13 14 15 |
# File 'lib/sepa_file_parser/general/record.rb', line 13 def amount SepaFileParser::Misc.to_amount(@amount) end |
#amount_in_cents ⇒ Object
17 18 19 |
# File 'lib/sepa_file_parser/general/record.rb', line 17 def amount_in_cents SepaFileParser::Misc.to_amount_in_cents(@amount) end |
#charges_included? ⇒ Boolean
29 30 31 |
# File 'lib/sepa_file_parser/general/record.rb', line 29 def charges_included? @charges_included ||= xml_data.xpath('ChrgInclInd/text()').text.downcase == 'true' end |
#credit? ⇒ Boolean
37 38 39 |
# File 'lib/sepa_file_parser/general/record.rb', line 37 def credit? !debit end |
#currency ⇒ Object
21 22 23 |
# File 'lib/sepa_file_parser/general/record.rb', line 21 def currency @currency ||= xml_data.xpath('Amt/@Ccy').text end |
#debit ⇒ Object
33 34 35 |
# File 'lib/sepa_file_parser/general/record.rb', line 33 def debit @debit ||= xml_data.xpath('CdtDbtInd/text()').text.upcase == 'DBIT' end |
#debit? ⇒ Boolean
41 42 43 |
# File 'lib/sepa_file_parser/general/record.rb', line 41 def debit? debit end |
#sign ⇒ Object
45 46 47 |
# File 'lib/sepa_file_parser/general/record.rb', line 45 def sign credit? ? 1 : -1 end |
#type ⇒ Object
25 26 27 |
# File 'lib/sepa_file_parser/general/record.rb', line 25 def type @type ||= SepaFileParser::Type::Builder.build_type(xml_data.xpath('Tp')) end |