Sha256: 9d348eaafdb8e21bdfd44b06e5567642bfae83530544e0661bcafd1c95991ecb
Contents?: true
Size: 861 Bytes
Versions: 33
Compression:
Stored size: 861 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 def self.output_to(io) if block_given? prev_out = Thread.current[:stdout] Thread.current[:stdout] = io yield Thread.current[:stdout] = prev_out else Thread.current[:stdout] = io end end def output_to(io, &proc) self.class.output_to(io, &proc) end end
Version data entries
33 entries across 33 versions & 1 rubygems