class Sawmill::RecordProcessor::CountRecords

This processor reports the number of records processed.

Public Class Methods

new(opts_={}) click to toggle source

Create a count-records report.

Recognized options include:

:label

Label to use for the report. If provided, the report is returned as a string of the form “#{label}#{value}” If set to nil or absent, the report is returned as an integer.

# File lib/sawmill/record_processor/count_records.rb, line 57
def initialize(opts_={})
  @label = opts_[:label]
  @finished = false
  @count = 0
end

Public Instance Methods

extra_entry(entry_) click to toggle source
# File lib/sawmill/record_processor/count_records.rb, line 69
def extra_entry(entry_)
  true
end
finish() click to toggle source
# File lib/sawmill/record_processor/count_records.rb, line 73
def finish
  @finished = true
  @label ? "#{@label}#{@count}" : @count
end
record(record_) click to toggle source
# File lib/sawmill/record_processor/count_records.rb, line 64
def record(record_)
  @count += 1 unless @finished
  true
end