Class: EntryCountProgressMeter
- Inherits:
-
ProgressMeter
- Object
- ProgressMeter
- EntryCountProgressMeter
- Defined in:
- lib/progress.rb
Overview
Progress meter that prints the number of entries parsed every (n) lines.
Instance Method Summary collapse
-
#initialize ⇒ EntryCountProgressMeter
constructor
A new instance of EntryCountProgressMeter.
-
#output_progress(entry) ⇒ Object
Outputs the number of entries that have been parsed so far (every once in a while).
Constructor Details
#initialize ⇒ EntryCountProgressMeter
Returns a new instance of EntryCountProgressMeter.
10 11 12 13 14 15 |
# File 'lib/progress.rb', line 10 def initialize # 'period' is how many entries we wait between printing output. So if 'period' is 10 000, # we'll print output every 10 000 lines. @_period = 10000 super end |
Instance Method Details
#output_progress(entry) ⇒ Object
Outputs the number of entries that have been parsed so far (every once in a while).
‘entry’ should be the latest log entry to be parsed, in hash form.
20 21 22 23 24 25 |
# File 'lib/progress.rb', line 20 def output_progress(entry) @_entry_count += 1 if @_entry_count % @_period == 0 puts "Processed %d entries" % [@_entry_count] end end |