Module: WrapIO

Defined in:
lib/capture_io.rb

Class Method Summary collapse

Class Method Details

.auto(to = 30, &blk) ⇒ Object

Raises:

  • (ArgumentError)


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/capture_io.rb', line 68

def self.auto(to=30, &blk)
  raise ArgumentError, "No Block Given" unless block_given?
  c = CaptureIO.new
  c.start

  results = blk.call
  
  timeout(to) {
    while results.kind_of?(Proc) 
      results = results.call
    end
  }
  
  out = c.stop
  out
end