Class: GraphKit::GnuplotPlotOptions

Inherits:
KitHash show all
Defined in:
lib/graphkit/gnuplot.rb

Constant Summary collapse

QUOTED =
["title"]
GNUPLOT_SETS =
%w[ function using axes title with ].map{|s| s.to_sym}

Instance Method Summary collapse

Methods inherited from KitHash

from_hash, #inspect

Methods included from Kit

#check, #method_missing

Methods inherited from Hash

#modify

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Kit

Instance Method Details

#[]=(opt, val) ⇒ Object



211
212
213
214
# File 'lib/graphkit/gnuplot.rb', line 211

def []=(opt, val)
  raise "#{opt} is not a valid gnuplot set option" unless GNUPLOT_SETS.include? opt
  super
end

#apply(io) ⇒ Object



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/graphkit/gnuplot.rb', line 215

def apply(io)
    self[:function] ||= "'-'"
    GNUPLOT_SETS.each do |var|
      val = send(var)
      next unless val
      case var
      when :function
        io << " #{val} "
      when :title
        io << "#{var} '#{val}'"
      else
        if QUOTED.include? var.to_s and not val =~ Regexp.quoted_string
          io << "#{var} '#{val}' "
        else
          io << "#{var} #{val} "
        end
      end
    end

end