Class: Ubalo::Logger
- Inherits:
-
Object
- Object
- Ubalo::Logger
- Defined in:
- lib/ubalo/logger.rb
Instance Method Summary collapse
- #complete_line ⇒ Object
-
#initialize(tty) ⇒ Logger
constructor
A new instance of Logger.
- #poll ⇒ Object
- #poll_on(message) ⇒ Object
- #print(str) ⇒ Object
- #puts(str = "") ⇒ Object
- #tty? ⇒ Boolean
Constructor Details
#initialize(tty) ⇒ Logger
Returns a new instance of Logger.
3 4 5 6 |
# File 'lib/ubalo/logger.rb', line 3 def initialize tty @incomplete_line = false @tty = tty end |
Instance Method Details
#complete_line ⇒ Object
22 23 24 25 |
# File 'lib/ubalo/logger.rb', line 22 def complete_line $stderr.print("\n") if @incomplete_line @incomplete_line = false end |
#poll ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ubalo/logger.rb', line 27 def poll 600.times do if result = yield return result end sleep 0.5 end self.complete_line raise Ubalo::Error, "timed-out while waiting" end |
#poll_on(message) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ubalo/logger.rb', line 39 def poll_on() self.print result = poll do self.print '.' yield end self.puts " done." result end |
#print(str) ⇒ Object
12 13 14 15 |
# File 'lib/ubalo/logger.rb', line 12 def print(str) @incomplete_line = true $stderr.print(str) end |
#puts(str = "") ⇒ Object
17 18 19 20 |
# File 'lib/ubalo/logger.rb', line 17 def puts(str="") @incomplete_line = false $stderr.print(str + "\n") end |
#tty? ⇒ Boolean
8 9 10 |
# File 'lib/ubalo/logger.rb', line 8 def tty? @tty end |