Class: Croaky::Stream::JavaStdOutStream

Inherits:
StdOutStream show all
Defined in:
lib/croaky/stream/java_std_out_stream.rb

Overview

Output stream for Java

Instance Attribute Summary collapse

Attributes inherited from StdOutStream

#stdout_str_io

Instance Method Summary collapse

Instance Attribute Details

#java_stdoutObject

Returns the value of attribute java_stdout.



11
12
13
# File 'lib/croaky/stream/java_std_out_stream.rb', line 11

def java_stdout
  @java_stdout
end

#pw_outObject

Returns the value of attribute pw_out.



11
12
13
# File 'lib/croaky/stream/java_std_out_stream.rb', line 11

def pw_out
  @pw_out
end

Instance Method Details

#capture_ioObject



13
14
15
16
17
18
19
20
# File 'lib/croaky/stream/java_std_out_stream.rb', line 13

def capture_io
  super

  self.java_stdout = java.lang.System.out
  pw_out&.close
  self.pw_out = out_stream
  java.lang.System.setOut(pw_out)
end

#read_captured_ioObject



29
30
31
32
33
# File 'lib/croaky/stream/java_std_out_stream.rb', line 29

def read_captured_io
  captured = super

  captured << read_out_stream
end

#restore_ioObject



22
23
24
25
26
27
# File 'lib/croaky/stream/java_std_out_stream.rb', line 22

def restore_io
  super

  java.lang.System.setOut(java_stdout)
  pw_out.close
end