Module: RedPlot

Defined in:
lib/redplot.rb

Overview

main namespace also used for mixin

Defined Under Namespace

Classes: Plotter, ToDraw

Class Method Summary collapse

Class Method Details

.extended(who) ⇒ Object

if an object extends RedPlot, RedPlot adds itself to the object via its eigenclass



207
208
209
# File 'lib/redplot.rb', line 207

def extended who
  insert in: who.singleton_class, as: :plot
end

.included(who) ⇒ Object

if a class includes RedPlot, RedPlot inserts itself in the class instead



202
203
204
# File 'lib/redplot.rb', line 202

def included who
  insert in: who, as: :plot
end

.insert(args, &block) ⇒ Object

this method takes a class and adds an attr_reader to it it also adds a lazy initialization reader with a shortcut name ! a call to the attr_reader before a call to the shorcut reader will return nil



214
215
216
217
218
219
220
221
# File 'lib/redplot.rb', line 214

def insert(args, &block)
  target = args[:in]  
  name   = args[:as] || :plot
  target.class_eval do 
    attr_reader :gnuplot_wrapper
    define_method(name) { @gnuplot_wrapper ||= RedPlot::Plotter.new(args,&block) }
  end if target.is_a? Class
end

.versionObject

returns a string with version number



224
225
226
# File 'lib/redplot.rb', line 224

def version
  'RedPlot version "%s" (%s)' % [RedPlot::VersionNumber, RedPlot::VersionDate]
end