Class: Stdout::Output
- Inherits:
-
Object
- Object
- Stdout::Output
- Defined in:
- lib/stdout/output.rb
Instance Attribute Summary collapse
-
#dump ⇒ Object
Returns the value of attribute dump.
-
#print ⇒ Object
Returns the value of attribute print.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Output
constructor
A new instance of Output.
- #write(msg) ⇒ Object
Constructor Details
#initialize ⇒ Output
Returns a new instance of Output.
13 14 15 16 |
# File 'lib/stdout/output.rb', line 13 def initialize @print = [] @dump = [] end |
Instance Attribute Details
#dump ⇒ Object
Returns the value of attribute dump.
11 12 13 |
# File 'lib/stdout/output.rb', line 11 def dump @dump end |
#print ⇒ Object
Returns the value of attribute print.
11 12 13 |
# File 'lib/stdout/output.rb', line 11 def print @print end |
Class Method Details
.capture(sep = $/) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/stdout/output.rb', line 21 def capture(sep = $/) output = self.new saved_stdout = $stdout $stdout = output yield $stdout = saved_stdout output.print.join.each_line(sep = sep) {|line| output.dump.push(line) } return output.dump end |
Instance Method Details
#write(msg) ⇒ Object
18 |
# File 'lib/stdout/output.rb', line 18 def write(msg); @print.push(msg); end |