Class: SepaFileParser::Creditor
- Inherits:
-
Object
- Object
- SepaFileParser::Creditor
- Defined in:
- lib/sepa_file_parser/general/creditor.rb
Instance Attribute Summary collapse
-
#xml_data ⇒ Object
readonly
Returns the value of attribute xml_data.
Instance Method Summary collapse
- #bank_name ⇒ Object
- #bic ⇒ Object
- #iban ⇒ Object
-
#initialize(xml_data) ⇒ Creditor
constructor
A new instance of Creditor.
- #name ⇒ Object
- #postal_address ⇒ SepaFileParser::PostalAddress?
Constructor Details
#initialize(xml_data) ⇒ Creditor
Returns a new instance of Creditor.
8 9 10 |
# File 'lib/sepa_file_parser/general/creditor.rb', line 8 def initialize(xml_data) @xml_data = xml_data end |
Instance Attribute Details
#xml_data ⇒ Object (readonly)
Returns the value of attribute xml_data.
6 7 8 |
# File 'lib/sepa_file_parser/general/creditor.rb', line 6 def xml_data @xml_data end |
Instance Method Details
#bank_name ⇒ Object
30 31 32 |
# File 'lib/sepa_file_parser/general/creditor.rb', line 30 def bank_name @bank_name ||= xml_data.xpath('RltdAgts/CdtrAgt/FinInstnId/Nm/text()').text end |
#bic ⇒ Object
23 24 25 26 27 28 |
# File 'lib/sepa_file_parser/general/creditor.rb', line 23 def bic @bic ||= [ xml_data.xpath('RltdAgts/CdtrAgt/FinInstnId/BIC/text()').text, xml_data.xpath('RltdAgts/CdtrAgt/FinInstnId/BICFI/text()').text, ].reject(&:empty?).first.to_s end |
#iban ⇒ Object
19 20 21 |
# File 'lib/sepa_file_parser/general/creditor.rb', line 19 def iban @iban ||= xml_data.xpath('RltdPties/CdtrAcct/Id/IBAN/text()').text end |
#name ⇒ Object
12 13 14 15 16 17 |
# File 'lib/sepa_file_parser/general/creditor.rb', line 12 def name @name ||= [ xml_data.xpath('RltdPties/Cdtr/Nm/text()').text, xml_data.xpath('RltdPties/Cdtr/Pty/Nm/text()').text, ].reject(&:empty?).first.to_s end |
#postal_address ⇒ SepaFileParser::PostalAddress?
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/sepa_file_parser/general/creditor.rb', line 35 def postal_address # May be missing postal_address = [ xml_data.xpath('RltdPties/Cdtr/PstlAdr'), xml_data.xpath('RltdPties/Cdtr/Pty/PstlAdr'), ].reject(&:empty?).first return nil if postal_address == nil || postal_address.empty? @address ||= SepaFileParser::PostalAddress.new(postal_address) end |