class GnuPlotter::DataSet
Nested class for GnuPlot datasets.
Public Class Methods
new(options = {})
click to toggle source
Constructor for the DataSet
object.
# File lib/gnuplotter.rb, line 199 def initialize(options = {}) @options = options @file = Tempfile.new("gp") @io = @file.open end
Public Instance Methods
<<(*obj)
click to toggle source
Write method.
# File lib/gnuplotter.rb, line 206 def <<(*obj) @io.puts obj.join(" ") end
Also aliased as: write
close()
click to toggle source
Method to close a DataSet
temporary file io.
# File lib/gnuplotter.rb, line 213 def close @io.close unless @io.closed? end
delete()
click to toggle source
Method to delete a DataSet
temporary file.
# File lib/gnuplotter.rb, line 218 def delete @io.close unless @io.closed? @file.unlink if File.exist? @file.path end
format_data()
click to toggle source
Method that returns data lines from file.
# File lib/gnuplotter.rb, line 245 def format_data lines = [] @io.close if @io.respond_to? :close File.open(@file) do |ios| ios.each do |line| line.chomp! lines << line end end lines end
format_options(input = nil)
click to toggle source
Method that builds a plot/splot command string from dataset options.
# File lib/gnuplotter.rb, line 224 def format_options(input = nil) options = [] if input options << %Q{"-"} else options << %Q{"#{@file.path}"} end @options.each do |key, value| if value == :true options << "#{key}" else options << "#{key} #{value}" end end options.join(" ") end