Class: Audition::Progress::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/audition/progress.rb

Overview

Shared by the renderers: both write to a stream that may go away, both spell out counts and durations the same way, and both paint with the palette the report uses.

Direct Known Subclasses

Line, Log

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, style: nil) ⇒ Renderer

Returns a new instance of Renderer.

Parameters:

  • io (IO)
  • style (Report::Style) (defaults to: nil) —

    defaults to whatever the stream supports, so a redirected run comes out plain



26
27
28
29
30
# File 'lib/audition/progress.rb', line 26

def initialize(io, style: nil)
  @io = io
  @style = style || Report::Style.detect(io: io)
  @live = true
end

Class Method Details

.terminal?(io) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/audition/progress.rb', line 17

def self.terminal?(io)
  io.respond_to?(:tty?) && io.tty?
rescue IOError
  false
end

Instance Method Details

#clear ⇒ Object



40
# File 'lib/audition/progress.rb', line 40

def clear = nil

#item(progress) ⇒ Object

A named unit is still just progress unless the renderer has a reason to treat it differently.



36
# File 'lib/audition/progress.rb', line 36

def item(progress) = update(progress)

#phase_done(progress) ⇒ Object



38
# File 'lib/audition/progress.rb', line 38

def phase_done(progress) = nil

#update(progress) ⇒ Object



32
# File 'lib/audition/progress.rb', line 32

def update(progress) = nil