Class: CodaStandard::Record
- Inherits:
-
Object
- Object
- CodaStandard::Record
- Defined in:
- lib/coda_standard/record.rb
Constant Summary collapse
- FIELDS =
{ current_bic: /^0.{59}(.{11})/, current_account: /^1(.{41})/, name: /^23.{45}(.{35})/, currency: /^23.{42}(.{3})/, entry_date: /^21.{113}(\d{6})/, reference_number: /^21.{8}(.{21})/, address: /^32.{8}(.{105})/, account: /^23\d{8}(\w+)\D/, bic: /^22.{96}(.{11})/, amount: /^21.{29}(\d{16})/, old_balance: /^1.{41}(\d)(\d{15})/, structured_communication: /^21.{60}(.{15})/, currencies: /(^.+)(AED|AFN|ALL|AMD|ANG|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BGN|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYR|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HRK|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LTL|LVL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRO|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLL|SOS|SRD|SSP|STD|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|USS|UYI|UYU|UZS|VEF|VND|VUV|WST|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XDR|XFU|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWL)/ }
- CLEAN_FIELDS =
{ clean_zeros: /0*(\d+)(\d{3})/, sep_address: /(^.+)(\d{4})\s(\S+)(\s\S+)?$/, sep_account: /(^.)(.{3})(.+)/, clean_structured: /.{3}(.{12})/, bban_be_account: /(^.{12})/, bban_foreign_account: /(^.{34})/, iban_be_account: /(^.{31})/, iban_foreign_account: /(^.{34})/ }
Instance Method Summary collapse
- #account ⇒ Object
- #address ⇒ Object
- #amount ⇒ Object
- #bic ⇒ Object
- #currency ⇒ Object
- #current_account ⇒ Object
- #current_bic ⇒ Object
- #data_information2? ⇒ Boolean
- #data_movement1? ⇒ Boolean
- #data_movement2? ⇒ Boolean
- #data_movement3? ⇒ Boolean
- #data_old_balance? ⇒ Boolean
- #entry_date ⇒ Object
- #field_valid?(field) ⇒ Boolean
- #header? ⇒ Boolean
-
#initialize(line) ⇒ Record
constructor
A new instance of Record.
- #name ⇒ Object
- #old_balance ⇒ Object
- #reference_number ⇒ Object
- #structured_communication ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(line) ⇒ Record
Returns a new instance of Record.
30 31 32 |
# File 'lib/coda_standard/record.rb', line 30 def initialize(line) @line = line end |
Instance Method Details
#account ⇒ Object
94 95 96 |
# File 'lib/coda_standard/record.rb', line 94 def account extract(:account) end |
#address ⇒ Object
98 99 100 |
# File 'lib/coda_standard/record.rb', line 98 def address extract(:address) end |
#amount ⇒ Object
78 79 80 |
# File 'lib/coda_standard/record.rb', line 78 def amount extract(:amount) end |
#bic ⇒ Object
82 83 84 |
# File 'lib/coda_standard/record.rb', line 82 def bic extract(:bic) end |
#currency ⇒ Object
86 87 88 |
# File 'lib/coda_standard/record.rb', line 86 def currency extract(:currency) end |
#current_account ⇒ Object
62 63 64 |
# File 'lib/coda_standard/record.rb', line 62 def current_account extract(:current_account) end |
#current_bic ⇒ Object
58 59 60 |
# File 'lib/coda_standard/record.rb', line 58 def current_bic extract(:current_bic) end |
#data_information2? ⇒ Boolean
54 55 56 |
# File 'lib/coda_standard/record.rb', line 54 def data_information2? @line.start_with? "32" end |
#data_movement1? ⇒ Boolean
42 43 44 |
# File 'lib/coda_standard/record.rb', line 42 def data_movement1? @line.start_with? "21" end |
#data_movement2? ⇒ Boolean
46 47 48 |
# File 'lib/coda_standard/record.rb', line 46 def data_movement2? @line.start_with? "22" end |
#data_movement3? ⇒ Boolean
50 51 52 |
# File 'lib/coda_standard/record.rb', line 50 def data_movement3? @line.start_with? "23" end |
#data_old_balance? ⇒ Boolean
38 39 40 |
# File 'lib/coda_standard/record.rb', line 38 def data_old_balance? @line.start_with? "1" end |
#entry_date ⇒ Object
70 71 72 |
# File 'lib/coda_standard/record.rb', line 70 def entry_date extract(:entry_date) end |
#field_valid?(field) ⇒ Boolean
113 114 115 116 117 118 |
# File 'lib/coda_standard/record.rb', line 113 def field_valid?(field) if field == :current_account return raw_extract(:current_account).scan(CLEAN_FIELDS[:sep_account]).flatten.size == 3 end true end |
#header? ⇒ Boolean
34 35 36 |
# File 'lib/coda_standard/record.rb', line 34 def header? @line.start_with? "0" end |
#name ⇒ Object
90 91 92 |
# File 'lib/coda_standard/record.rb', line 90 def name extract(:name) end |
#old_balance ⇒ Object
66 67 68 |
# File 'lib/coda_standard/record.rb', line 66 def old_balance extract(:old_balance) end |
#reference_number ⇒ Object
74 75 76 |
# File 'lib/coda_standard/record.rb', line 74 def reference_number extract(:reference_number) end |
#structured_communication ⇒ Object
102 103 104 |
# File 'lib/coda_standard/record.rb', line 102 def structured_communication extract(:structured_communication) end |
#valid? ⇒ Boolean
106 107 108 109 110 111 |
# File 'lib/coda_standard/record.rb', line 106 def valid? if data_old_balance? return false if !field_valid?(:current_account) end true end |