Class: TestOwl::Teeio
- Inherits:
-
Object
- Object
- TestOwl::Teeio
- Defined in:
- lib/testowl/teeio.rb
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize ⇒ Teeio
constructor
A new instance of Teeio.
- #output ⇒ Object
- #puts(buf) ⇒ Object
- #run(command) ⇒ Object
- #write(buf) ⇒ Object
Constructor Details
#initialize ⇒ Teeio
17 18 19 20 |
# File 'lib/testowl/teeio.rb', line 17 def initialize @results = [] @file = Tempfile.new('testowl') end |
Instance Method Details
#flush ⇒ Object
36 37 38 |
# File 'lib/testowl/teeio.rb', line 36 def flush $stdout.flush end |
#output ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/testowl/teeio.rb', line 40 def output if @results.size == 0 IO.read(@file.path) else @results.join end end |
#puts(buf) ⇒ Object
31 32 33 34 |
# File 'lib/testowl/teeio.rb', line 31 def puts(buf) @results << buf $stdout.puts buf end |
#run(command) ⇒ Object
22 23 24 |
# File 'lib/testowl/teeio.rb', line 22 def run(command) system("#{command} | tee #{@file.path}") end |
#write(buf) ⇒ Object
26 27 28 29 |
# File 'lib/testowl/teeio.rb', line 26 def write(buf) @results << buf $stdout.write buf end |