From: Joel VanderWerf Date: 2009-06-05T03:38:48+09:00 Subject: Re: Use methods from a library in my own class Jason Lillywhite wrote: > I want to create a class that uses the RubyGnuplot library that can > create a plot using one simple command and only add options if so > desired. Below is what I have done so far and I was wondering if someone > could provide some opinion on my approach. I ran into a problem where I > allow the user to add 3 options but what I really want is access to all > the library's methods so colors and lineweights, etc can be changed if > so desired. Is there a better approach than using a hash input like I'm > doing? Thank you! > > #For simple 2D line plots. File is called 'my_plotter.rb' > > require 'gnuplot' > class Data2d > def self.plot(x, y, options={}) > Gnuplot.open do |gp| > Gnuplot::Plot.new( gp ) do |plot| > > plot.title "#{options[:title]}" > plot.ylabel "#{options[:y_label]}" > plot.xlabel "#{options[:x_label]}" Untested... options.each {|opt,val| plot.send opt, val} -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407