Class: FancyIrb::ErrorCapturer

Inherits:
Object
  • Object
show all
Defined in:
lib/fancy_irb/error_capturer.rb

Instance Method Summary collapse

Constructor Details

#initializeErrorCapturer

Returns a new instance of ErrorCapturer.



5
6
7
8
# File 'lib/fancy_irb/error_capturer.rb', line 5

def initialize
  @original_stdout, $stdout = $stdout, StringIO.new
  @fake_stdout = $stdout
end

Instance Method Details

#error_stringObject



10
11
12
# File 'lib/fancy_irb/error_capturer.rb', line 10

def error_string
  @fake_stdout.string
end

#restore_original_stdoutObject



14
15
16
# File 'lib/fancy_irb/error_capturer.rb', line 14

def restore_original_stdout
  $stdout = @original_stdout
end