Class: Impala::ProgressReporter
- Inherits:
-
Object
- Object
- Impala::ProgressReporter
- Defined in:
- lib/impala/progress_reporter.rb
Instance Method Summary collapse
-
#initialize(cursor, options = {}) ⇒ ProgressReporter
constructor
A new instance of ProgressReporter.
- #report ⇒ Object
- #show? ⇒ Boolean
Constructor Details
#initialize(cursor, options = {}) ⇒ ProgressReporter
Returns a new instance of ProgressReporter.
3 4 5 6 7 8 |
# File 'lib/impala/progress_reporter.rb', line 3 def initialize(cursor, = {}) @cursor = cursor @progress_every = .fetch(:progress_every, 60).to_f @show_progress = .fetch(:show_progress, false) @start_time = @last_progress = Time.now end |
Instance Method Details
#report ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/impala/progress_reporter.rb', line 14 def report return unless enough_time_elapsed? @last_progress = Time.now = sprintf("Progress %.02f%% after %.02f seconds", cursor.progress * 100, total_time_elapsed) progress_stream.puts end |
#show? ⇒ Boolean
10 11 12 |
# File 'lib/impala/progress_reporter.rb', line 10 def show? @show_progress end |