Class: GraphKit::MultiKit

Inherits:
Array
  • Object
show all
Includes:
Writer
Defined in:
lib/graphkit.rb,
lib/graphkit/gnuplot.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Writer

#gnuplot_write

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



575
576
577
# File 'lib/graphkit/gnuplot.rb', line 575

def method_missing(meth, *args)
  self[0].send(meth, *args)
end

Class Method Details

.uninspect(arr, ivars) ⇒ Object



281
282
283
284
285
286
287
# File 'lib/graphkit.rb', line 281

def self.uninspect(arr, ivars)
  mkit = new(arr)
  ivars.each do |var,val|
    mkit.instance_variable_set(var,val)
  end
  mkit
end

Instance Method Details

#+(other) ⇒ Object



295
296
297
# File 'lib/graphkit.rb', line 295

def +(other)
  merge(other)
end

#gnuplot(*args) ⇒ Object



579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
# File 'lib/graphkit/gnuplot.rb', line 579

def gnuplot(*args)
    meth = :gnuplot
    #unless [:gnuplot, :gnuplot_write].include? 
	if args[-1].kind_of? Hash
	options = args.pop 
	else 
		options = {}
	end
	raise "Nothing to plot: size = 0" if size==0
	#self[0].gp.multiplot = options[:multiplot] || "layout #{size},1"
	gp.multiplot ||= options[:multiplot] || "layout #{size},1"
	for i in 0...self.size
		self[i].gp.multiplot_following = true
	end
	Gnuplot.open(true) do |io|
		@gnuplot_sets.apply(io)
		options[:io] = io
		each do |gk|
			#p gk.to_s
			gk
			gk.send(meth, *args, options)
		end
		options.delete(:io)
	end
	for i in 0...self.size
		self[i].multiplot_following = false
	end
end

#gnuplot_setsObject Also known as: gp



568
569
570
571
572
# File 'lib/graphkit/gnuplot.rb', line 568

def gnuplot_sets
	# gnuplot_options included for back. comp
	@gnuplot_sets ||=  GnuplotSetOptions.new
	@gnuplot_sets
end

#inspectObject



299
300
301
# File 'lib/graphkit.rb', line 299

def inspect
  "GraphKit::MultiKit.uninspect(#{super}, :@gnuplot_sets=>#{@gnuplot_sets.inspect})"
end

#merge(other) ⇒ Object



288
289
290
291
292
293
# File 'lib/graphkit.rb', line 288

def merge(other)
	size.times do |i|
	 self[i] += other[i] if other[i]
	end
	self
end