Top Level Namespace

Defined Under Namespace

Modules: Plotrobber

Instance Method Summary collapse

Instance Method Details

#before_each_plot(&blk) ⇒ Object



24
25
26
# File 'lib/plotrobber.rb', line 24

def before_each_plot(&blk)
  Plotrobber::PlotWrapper.before_each = blk
end

#plot(filename = nil, &blk) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/plotrobber.rb', line 29

def plot(filename=nil, &blk)
  p = Plotrobber::PlotWrapper.new

  p.magic_terminal(filename) if filename

  p.instance_exec(&Plotrobber::PlotWrapper.before_each) if Plotrobber::PlotWrapper.before_each

  p.instance_exec(p, &blk)

  @@gp << p.to_s << "\nreset\n"
end

#plotting(preserve = false, &blk) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/plotrobber.rb', line 4

def plotting(preserve=false, &blk)
  if ENV['DEBUG']
    @@gp = STDOUT
    blk[STDOUT]
  else
    cmd = 'gnuplot'
    cmd << ' -preserve' if preserve

    IO.popen(cmd, 'w+') do |io|
      @@gp = io
      blk[io]
    end
  end
end