Class: CamtParser::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/camt_parser/general/record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_data) ⇒ Record

Returns a new instance of Record.



6
7
8
9
# File 'lib/camt_parser/general/record.rb', line 6

def initialize(xml_data)
  @xml_data = xml_data
  @amount = xml_data.xpath('Amt/text()').text
end

Instance Attribute Details

#xml_dataObject (readonly)

Returns the value of attribute xml_data.



4
5
6
# File 'lib/camt_parser/general/record.rb', line 4

def xml_data
  @xml_data
end

Instance Method Details

#amountObject



11
12
13
# File 'lib/camt_parser/general/record.rb', line 11

def amount
  CamtParser::Misc.to_amount(@amount)
end

#amount_in_centsObject



15
16
17
# File 'lib/camt_parser/general/record.rb', line 15

def amount_in_cents
  CamtParser::Misc.to_amount_in_cents(@amount)
end

#charges_included?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/camt_parser/general/record.rb', line 27

def charges_included?
  @charges_included ||= xml_data.xpath('ChrgInclInd/text()').text.downcase == 'true'
end

#credit?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/camt_parser/general/record.rb', line 35

def credit?
  !debit
end

#currencyObject



19
20
21
# File 'lib/camt_parser/general/record.rb', line 19

def currency
  @currency ||= xml_data.xpath('Amt/@Ccy').text
end

#debitObject



31
32
33
# File 'lib/camt_parser/general/record.rb', line 31

def debit
  @debit ||= xml_data.xpath('CdtDbtInd/text()').text.upcase == 'DBIT'
end

#debit?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/camt_parser/general/record.rb', line 39

def debit?
  debit
end

#signObject



43
44
45
# File 'lib/camt_parser/general/record.rb', line 43

def sign
  credit? ? 1 : -1
end

#typeObject



23
24
25
# File 'lib/camt_parser/general/record.rb', line 23

def type
  @type ||= CamtParser::Type::Builder.build_type(xml_data.xpath('Tp'))
end