Module: Philiprehberger::CsvKit::Callbacks

Included in:
Processor
Defined in:
lib/philiprehberger/csv_kit/callbacks.rb

Overview

Mixin for column aliasing and row callbacks.

Instance Method Summary collapse

Instance Method Details

#after_each {|Row| ... } ⇒ Object

Register a callback to run after each row is processed.

Yields:

  • (Row)

    the processed row



10
11
12
# File 'lib/philiprehberger/csv_kit/callbacks.rb', line 10

def after_each(&block)
  @after_each_block = block
end

#rename(from, to) ⇒ Object

Rename a column during processing.

Parameters:

  • from (Symbol)

    original column name

  • to (Symbol)

    new column name



18
19
20
# File 'lib/philiprehberger/csv_kit/callbacks.rb', line 18

def rename(from, to)
  @renames[from.to_sym] = to.to_sym
end