Module: Hakoy::FileAppender

Extended by:
FileAppender
Included in:
FileAppender
Defined in:
lib/hakoy/file_appender.rb,
lib/hakoy/file_appender/csv.rb

Defined Under Namespace

Modules: Csv

Instance Method Summary collapse

Instance Method Details

#append(file_path, rows_hash, opts = {}) ⇒ Object Also known as: call



5
6
7
8
9
10
11
12
13
14
# File 'lib/hakoy/file_appender.rb', line 5

def append(file_path, rows_hash, opts={})
  dir      = File.dirname(file_path)
  extname  = File.extname(file_path)
  strategy = opts.delete(:strategy)

  ensure_dir_exist(dir)

  strategy ||= find_strategy(extname)
  strategy.(file_path, rows_hash, opts)
end