Class: Cmxl::Fields::StatementDetails
Constant Summary
Constants inherited
from Cmxl::Field
Cmxl::Field::DATE
Instance Attribute Summary
Attributes inherited from Cmxl::Field
#data, #match, #modifier, #source, #tag
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Cmxl::Field
#add_meta_data, #initialize, #method_missing, parsers, #to_amount, #to_amount_in_cents, #to_date, #to_hash, #to_json
Constructor Details
This class inherits a constructor from Cmxl::Field
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Cmxl::Field
Class Method Details
.parse(line) ⇒ Object
8
9
10
11
|
# File 'lib/cmxl/fields/statement_details.rb', line 8
def parse(line)
super line.gsub(/\R?/, '')
end
|
Instance Method Details
#bic ⇒ Object
45
46
47
|
# File 'lib/cmxl/fields/statement_details.rb', line 45
def bic
sub_fields['30']
end
|
#description ⇒ Object
22
23
24
|
# File 'lib/cmxl/fields/statement_details.rb', line 22
def description
sub_fields['00'] || data['details']
end
|
#iban ⇒ Object
53
54
55
|
# File 'lib/cmxl/fields/statement_details.rb', line 53
def iban
sub_fields['38'] || sub_fields['31']
end
|
26
27
28
29
|
# File 'lib/cmxl/fields/statement_details.rb', line 26
def information
info = (20..29).to_a.collect { |i| sub_fields[i.to_s] }.join('')
info.empty? ? description : info
end
|
#name ⇒ Object
49
50
51
|
# File 'lib/cmxl/fields/statement_details.rb', line 49
def name
[sub_fields['32'], sub_fields['33']].compact.join(' ')
end
|
#primanota ⇒ Object
41
42
43
|
# File 'lib/cmxl/fields/statement_details.rb', line 41
def primanota
sub_fields['10']
end
|
#sepa ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/cmxl/fields/statement_details.rb', line 31
def sepa
if information =~ /([A-Z]{4})\+/
Hash[
*information.split(/([A-Z]{4})\+/)[1..-1].tap { |info| info << '' if info.size.odd? }
]
else
{}
end
end
|
#sub_fields ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/cmxl/fields/statement_details.rb', line 14
def sub_fields
@sub_fields ||= if data['details'] =~ /#{Regexp.escape(data['seperator'])}(\d{2})/
Hash[data['details'].scan(/#{Regexp.escape(data['seperator'])}(\d{2})([^#{Regexp.escape(data['seperator'])}]*)/)]
else
{}
end
end
|
#to_h ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/cmxl/fields/statement_details.rb', line 57
def to_h
{
'bic' => bic,
'iban' => iban,
'name' => name,
'sepa' => sepa,
'information' => information,
'description' => description,
'sub_fields' => sub_fields,
'transaction_code' => transaction_code,
'primanota' => primanota,
'details' => details
}
end
|