Class: NumPlot::Process
- Inherits:
-
Object
- Object
- NumPlot::Process
- Defined in:
- lib/numplot.rb
Overview
The class communicating a gnuplot subprocess.
In many cases, you use NumPlot::Plotter#plot and you don't need to use this class directly.
Instance Attribute Summary (collapse)
-
- (String?) output
readonly
Output string from a gnuplot subprocess.
Class Method Summary (collapse)
-
+ (Object) open(persist = true, waiting = true, name = "gnuplot")
Open a gnuplot process.
Instance Method Summary (collapse)
-
- (void) close
Close the pipe and terminate the subprocess.
-
- (Process) initialize(pipe, wait)
constructor
Create a Process object for already opened pipe.
-
- (void) puts(str)
Write
str
and a newline to the subprocess. -
- (void) write(str)
Write
str
to the subprocess.
Constructor Details
Instance Attribute Details
- (String?) output (readonly)
Output string from a gnuplot subprocess.
170 171 172 |
# File 'lib/numplot.rb', line 170 def output @output end |
Class Method Details
+ (Object) open(persist = true, waiting = true, name = "gnuplot")
Open a gnuplot process.
If a block is given, the block is invoked with the opened Process object.
Otherwise, opened Process object is returned. If you give true as
persist
, -persist option is added to the command line of
gnuplot.
207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/numplot.rb', line 207 def self.open(persist=true, waiting=true, name="gnuplot") pr = new(IO.popen(command(name, persist), "w+"), waiting) if block_given? begin yield pr ensure pr.close end return pr.output else return pr end end |
Instance Method Details
- (void) close
This method returns an undefined value.
Close the pipe and terminate the subprocess.
If you specify wait=true when the object is constructed,
176 177 178 179 180 181 182 183 184 |
# File 'lib/numplot.rb', line 176 def close if @wait @pipe.close_write @output = @pipe.read @pipe.close else @pipe.close end end |
- (void) puts(str)
This method returns an undefined value.
Write str
and a newline to the subprocess
194 195 196 |
# File 'lib/numplot.rb', line 194 def puts(str) @pipe.puts(str) end |
- (void) write(str)
This method returns an undefined value.
Write str
to the subprocess.
188 189 190 |
# File 'lib/numplot.rb', line 188 def write(str) @pipe.write(str) end |