Class: BanklineCsvImportFile::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/bankline_csv_import_file/record.rb

Instance Method Summary collapse

Constructor Details

#initializeRecord

Returns a new instance of Record.



3
4
5
6
# File 'lib/bankline_csv_import_file/record.rb', line 3

def initialize
  # H001..H003, T001..T082.
  @array = Array.new(85)
end

Instance Method Details

#[]=(key, value) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bankline_csv_import_file/record.rb', line 8

def []=(key, value)
  case key
  when "H001" then @array[0] = value
  when "H002" then @array[1] = value
  when "H003" then @array[2] = value
  when /\AT(\d\d\d)\z/
    i = $1.to_i
    raise "Out of range!" unless (1..82).cover?(i)
    @array[i + 2] = value
  else
    raise "Unknown field: #{key.inspect}"
  end
end

#to_csvObject



22
23
24
# File 'lib/bankline_csv_import_file/record.rb', line 22

def to_csv
  @array
end