Class: Numo::Gnuplot::OptsToS

Inherits:
Object
  • Object
show all
Defined in:
lib/numo/gnuplot.rb

Instance Method Summary collapse

Constructor Details

#initialize(*opts) ⇒ OptsToS

:nodoc: all



303
304
305
# File 'lib/numo/gnuplot.rb', line 303

def initialize(*opts)
  @opts = opts
end

Instance Method Details

#opts_to_s(*opts) ⇒ Object



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/numo/gnuplot.rb', line 311

def opts_to_s(*opts)
  #p opts
  sep = ","
  opts.map do |opt|
    sep = " " if !opt.kind_of?(Numeric)
    case opt
    when Array
      opt.map{|v| "#{opts_to_s(*v)}"}.join(sep)
    when Hash
      opt.map{|k,v| KvItem.new(k,v).to_s}.compact.join(" ")
    when Range
      "[#{opt.begin}:#{opt.end}]"
    else
      opt.to_s
    end
  end.join(sep)
end

#to_sObject



307
308
309
# File 'lib/numo/gnuplot.rb', line 307

def to_s
  opts_to_s(*@opts)
end