Class: Ubalo::Tailer
- Inherits:
-
Object
- Object
- Ubalo::Tailer
- Defined in:
- lib/ubalo/tailer.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(logger) ⇒ Tailer
constructor
A new instance of Tailer.
- #tty? ⇒ Boolean
- #update(message, output = nil) ⇒ Object
Constructor Details
#initialize(logger) ⇒ Tailer
Returns a new instance of Tailer.
3 4 5 6 |
# File 'lib/ubalo/tailer.rb', line 3 def initialize(logger) @logger = logger @output_position = 0 end |
Instance Method Details
#tty? ⇒ Boolean
8 9 10 |
# File 'lib/ubalo/tailer.rb', line 8 def tty? @logger.tty? end |
#update(message, output = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ubalo/tailer.rb', line 12 def update(, output=nil) # Erase current line. if tty? @logger.print "\r" @logger.print " " * Integer(Util.columns) @logger.print "\r" end if output @logger.print output[@output_position..-1] @output_position = output.length end if tty? @logger.print Color.green(wrap()) else @logger.puts wrap() end end |