Sha256: de766e30dacb4ea78ca43495ecf042b2dc04f4c5ce64839bacf9bc2ee879c512

Contents?: true

Size: 526 Bytes

Versions: 10

Compression:

Stored size: 526 Bytes

Contents

##
# Allows $stdout to be set via Thread.current[:stdout] per thread.
# By Eric Hodel, taken from http://blog.segment7.net/articles/2006/08/16/setting-stdout-per-thread

# Thread local $stdout.
module ThreadOut #:nodoc:

  ##
  # Writes to Thread.current[:stdout] instead of STDOUT if the thread local is
  # set.

  def self.write(stuff)
    if Thread.current[:stdout] then
      Thread.current[:stdout].write stuff 
    else
      STDOUT.write stuff
    end
  end
  
  def self.<<(stuff)
      self.write(stuff)
  end
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
spiderfw-0.5.10 lib/spiderfw/utils/thread_out.rb
spiderfw-0.5.9 lib/spiderfw/utils/thread_out.rb
spiderfw-0.5.7 lib/spiderfw/utils/thread_out.rb
spiderfw-0.5.6 lib/spiderfw/utils/thread_out.rb
spiderfw-0.5.5 lib/spiderfw/utils/thread_out.rb
spiderfw-0.5.4 lib/spiderfw/utils/thread_out.rb
spiderfw-0.5.3 lib/spiderfw/utils/thread_out.rb
spiderfw-0.5.2 lib/spiderfw/utils/thread_out.rb
spiderfw-0.5.1 lib/spiderfw/utils/thread_out.rb
spiderfw-0.5 lib/spiderfw/utils/thread_out.rb