Class: CamtParser::Record

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

Instance Method Summary collapse

Constructor Details

#initialize(xml_data) ⇒ Record

Returns a new instance of Record.



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

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

Instance Method Details

#amountObject



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

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

#amount_in_centsObject



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

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

#charges_included?Boolean

Returns:

  • (Boolean)


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

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

#credit?Boolean

Returns:

  • (Boolean)


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

def credit?
  !debit
end

#currencyObject



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

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

#debitObject



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

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

#debit?Boolean

Returns:

  • (Boolean)


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

def debit?
  debit
end

#signObject



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

def sign
  credit? ? 1 : -1
end

#typeObject



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

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