Class: ThreadOut

Inherits:
Object
  • Object
show all
Defined in:
lib/common/ext/stdout.rb

Instance Method Summary collapse

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

#flushObject



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


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