Class: Camt::Amount

Inherits:
Object
  • Object
show all
Defined in:
lib/camt/amount.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_node) ⇒ Amount

Returns a new instance of Amount.



6
7
8
# File 'lib/camt/amount.rb', line 6

def initialize(xml_node)
  @node = xml_node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



4
5
6
# File 'lib/camt/amount.rb', line 4

def node
  @node
end

Instance Method Details

#currencyObject



18
19
20
# File 'lib/camt/amount.rb', line 18

def currency
  node.at('./Amt').attribute('Ccy').value
end

#signObject



14
15
16
# File 'lib/camt/amount.rb', line 14

def sign
  node.at('./CdtDbtInd').text == 'DBIT' ? -1 : 1
end

#valueObject



10
11
12
# File 'lib/camt/amount.rb', line 10

def value
  sign * BigDecimal.new(node.at('./Amt').text)
end