Class: SepaClearer::DeutscheBundesbank
- Inherits:
-
Object
- Object
- SepaClearer::DeutscheBundesbank
- Defined in:
- lib/sepa_clearer/deutsche_bundesbank.rb
Constant Summary collapse
- MAPPING =
{ service_sct: :sct, service_sdd: :core, service_cor1: :cor1, service_b2b: :b2b }
Instance Method Summary collapse
Instance Method Details
#data(file = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/sepa_clearer/deutsche_bundesbank.rb', line 12 def data(file = nil) @data ||= begin [].tap do |data| CSV.foreach(file || default_data_file, { headers: true, col_sep: ';', header_converters: :symbol, encoding: "iso-8859-1:UTF-8" }) do |row| data.push PaymentProvider.new(parse_raw_data(row)) end end end end |
#default_data_file ⇒ Object
29 30 31 |
# File 'lib/sepa_clearer/deutsche_bundesbank.rb', line 29 def default_data_file File.join(File.dirname(__FILE__), '../..', 'data/deutsche_bundesbank.csv') end |
#parse_raw_data(data) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/sepa_clearer/deutsche_bundesbank.rb', line 22 def parse_raw_data(data) MAPPING.reduce({}) { |hsh,(key, service)| hsh[service] = (data[key] == '1'); hsh }.merge({ name: data[:name].strip.chomp, bic: data[:bic].strip.chomp, }) end |