Class: Numo::Gnuplot::NotePlot
- Inherits:
-
Object
- Object
- Numo::Gnuplot::NotePlot
- Defined in:
- lib/numo/gnuplot.rb
Instance Method Summary collapse
-
#initialize(&block) ⇒ NotePlot
constructor
A new instance of NotePlot.
- #to_iruby ⇒ Object
Constructor Details
#initialize(&block) ⇒ NotePlot
Returns a new instance of NotePlot.
31 32 33 34 35 36 |
# File 'lib/numo/gnuplot.rb', line 31 def initialize(&block) if block.nil? raise ArgumentError,"block is needed" end @block = block end |
Instance Method Details
#to_iruby ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/numo/gnuplot.rb', line 38 def to_iruby require 'tempfile' tempfile_svg = Tempfile.open(['plot','.svg']) # output SVG to tmpfile gp = Gnuplot.default gp.reset gp.set terminal:'svg' gp.set output:tempfile_svg.path gp.instance_eval(&@block) gp.unset 'output' svg = File.read(tempfile_svg.path) tempfile_svg.close ["image/svg+xml",svg] end |