Class: StIO

Inherits:
Object
  • Object
show all
Defined in:
lib/code_writer/rbmarkdown.rb

Overview

In some cases, there is the need to redirect standard output to a string. In general class StIO will do it without any problem. However, when integrating with some libraries, for instace, Renjin, Renjin standard output and Ruby standard output are different, so we need to redirect both standard outputs to the same string. The integrating library will have to implement methods set_std_out, set_std_err, set_default_std_out and set_default_std_err.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#alternate_errObject (readonly)

Returns the value of attribute alternate_err.



34
35
36
# File 'lib/code_writer/rbmarkdown.rb', line 34

def alternate_err
  @alternate_err
end

#alternate_outObject (readonly)

Returns the value of attribute alternate_out.



33
34
35
# File 'lib/code_writer/rbmarkdown.rb', line 33

def alternate_out
  @alternate_out
end

Instance Method Details

#set_default_std_outObject



46
47
48
# File 'lib/code_writer/rbmarkdown.rb', line 46

def set_default_std_out
  $stdout = STDOUT
end

#set_std_err(buffer) ⇒ Object



41
42
43
44
# File 'lib/code_writer/rbmarkdown.rb', line 41

def set_std_err(buffer)
  $stderr = StringIO.new(buffer)
  @alternate_err = buffer
end

#set_std_out(buffer) ⇒ Object



36
37
38
39
# File 'lib/code_writer/rbmarkdown.rb', line 36

def set_std_out(buffer)
  $stdout = StringIO.new(buffer)
  @alternate_out = buffer
end