Class: SepaFileParser::UltimateDebitor

Inherits:
Object
  • Object
show all
Defined in:
lib/sepa_file_parser/general/ultimate_debitor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_data) ⇒ UltimateDebitor

Returns a new instance of UltimateDebitor.



8
9
10
# File 'lib/sepa_file_parser/general/ultimate_debitor.rb', line 8

def initialize(xml_data)
  @xml_data = xml_data
end

Instance Attribute Details

#xml_dataObject (readonly)

Returns the value of attribute xml_data.



6
7
8
# File 'lib/sepa_file_parser/general/ultimate_debitor.rb', line 6

def xml_data
  @xml_data
end

Instance Method Details

#nameObject



12
13
14
15
16
17
# File 'lib/sepa_file_parser/general/ultimate_debitor.rb', line 12

def name
  @name ||= [
    xml_data.xpath('RltdPties/UltmtDbtr/Nm/text()').text,
    xml_data.xpath('RltdPties/UltmtDbtr/Pty/Nm/text()').text,
  ].reject(&:empty?).first.to_s
end

#postal_addressSepaFileParser::PostalAddress?



20
21
22
23
24
25
26
27
28
29
# File 'lib/sepa_file_parser/general/ultimate_debitor.rb', line 20

def postal_address # May be missing
  postal_address = [
    xml_data.xpath('RltdPties/Dbtr/PstlAdr'),
    xml_data.xpath('RltdPties/Dbtr/Pty/PstlAdr'),
  ].reject(&:empty?).first

  return nil if postal_address == nil || postal_address.empty?

  @address ||= SepaFileParser::PostalAddress.new(postal_address)
end