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.
6 7 8 |
# File 'lib/common/ext/stdout.rb', line 6 def initialize(out) @out = out end |
Instance Method Details
#flush ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/common/ext/stdout.rb', line 43 def flush if Thread.current[:stdout] then Thread.current[:stdout].flush else begin @out.flush rescue Exception end end end |
#print(stuff = '') ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/common/ext/stdout.rb', line 32 def print(stuff='') if Thread.current[:stdout] then Thread.current[:stdout].puts stuff else begin @out.print stuff rescue Exception end end end |
#puts(stuff = '') ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/common/ext/stdout.rb', line 21 def puts(stuff='') if Thread.current[:stdout] then Thread.current[:stdout].puts stuff else begin @out.puts stuff rescue Exception end end end |
#write(stuff = '') ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/common/ext/stdout.rb', line 10 def write(stuff='') if Thread.current[:stdout] then Thread.current[:stdout].write stuff else begin @out.write stuff rescue Exception end end end |