Class: Ke::SingleLineReporter
- Inherits:
-
Object
- Object
- Ke::SingleLineReporter
- Defined in:
- lib/ke/reporters/single_line_reporter.rb
Instance Method Summary collapse
-
#initialize(task, label, io = STDOUT) ⇒ SingleLineReporter
constructor
A new instance of SingleLineReporter.
- #print_complete ⇒ Object
- #print_start ⇒ Object
- #print_tick ⇒ Object
Constructor Details
#initialize(task, label, io = STDOUT) ⇒ SingleLineReporter
Returns a new instance of SingleLineReporter.
3 4 5 6 7 |
# File 'lib/ke/reporters/single_line_reporter.rb', line 3 def initialize(task, label, io = STDOUT) @task = task @label = label @io = io end |
Instance Method Details
#print_complete ⇒ Object
31 32 33 |
# File 'lib/ke/reporters/single_line_reporter.rb', line 31 def print_complete @io.puts " complete (#{@task.total_duration} total duration)." end |
#print_start ⇒ Object
9 10 11 |
# File 'lib/ke/reporters/single_line_reporter.rb', line 9 def print_start @io.print "Starting #{@label} ..." end |
#print_tick ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ke/reporters/single_line_reporter.rb', line 13 def print_tick ticks_per_second = (1 / @task.duration_per_tick).round(2) elapsed_time = (@task.elapsed_duration / 60.0).round(2) if @task.respond_to?(:estimated_duration_until_complete) estimated_duration_until_complete = (@task.estimated_duration_until_complete / 60.0).round(2) if @task.respond_to?(:total_ticks) pct = (@task.tick_count.to_f * 100 / @task.total_ticks).round(2) @io.print " #{elapsed_time}/#{estimated_duration_until_complete} mins, #{@task.tick_count}/#{@task.total_ticks} ticks ~ #{pct}% ..." else @io.print " #{elapsed_time}/#{estimated_duration_until_complete} mins ..." end else @io.print " #{elapsed_time} mins, #{ticks_per_second} ticks/sec ..." end end |