Class: ThreadOut
- Inherits:
-
Object
- Object
- ThreadOut
- Defined in:
- lib/common/ext/stdout.rb
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(out) ⇒ ThreadOut
constructor
A new instance of ThreadOut.
- #print(stuff = '') ⇒ Object
- #puts(stuff = '') ⇒ Object
- #write(stuff = '') ⇒ Object
Constructor Details
#initialize(out) ⇒ ThreadOut
Returns a new instance of ThreadOut.
5 6 7 |
# File 'lib/common/ext/stdout.rb', line 5 def initialize(out) @out = out end |
Instance Method Details
#flush ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/common/ext/stdout.rb', line 33 def flush if Thread.current[:stdout] then Thread.current[:stdout].flush else @out.flush end end |
#print(stuff = '') ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/common/ext/stdout.rb', line 25 def print(stuff='') if Thread.current[:stdout] then Thread.current[:stdout].puts stuff else @out.print stuff end end |
#puts(stuff = '') ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/common/ext/stdout.rb', line 17 def puts(stuff='') if Thread.current[:stdout] then Thread.current[:stdout].puts stuff else @out.puts stuff end end |
#write(stuff = '') ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/common/ext/stdout.rb', line 9 def write(stuff='') if Thread.current[:stdout] then Thread.current[:stdout].write stuff else @out.write stuff end end |