Class: Middleman::GnuplotExtension
- Inherits:
-
Extension
- Object
- Extension
- Middleman::GnuplotExtension
- Defined in:
- lib/middleman-gnuplot/extension.rb
Constant Summary collapse
- @@base_dir =
""
- @@plot_names =
[]
Instance Method Summary collapse
-
#initialize(app, options_hash = {}, &block) ⇒ GnuplotExtension
constructor
Initializes the middleman-gnuplot extension.
-
#plot_data(data, series = nil, filename = nil, title = nil) ⇒ Object
Generates a plot via gnuplot using the given data array The data array should be an array of rows that contains arrays of cols.
-
#plot_functions(functions = [], filename = nil, title = nil) ⇒ Object
The function must be provided as hash using the following fields:.
-
#plot_script(script, filename = nil, title = nil) ⇒ Object
Generates a plot directly from an existing gnuplot script Params:.
- #random_filename_if_nil(filename = nil, length = 6) ⇒ Object
Constructor Details
#initialize(app, options_hash = {}, &block) ⇒ GnuplotExtension
Initializes the middleman-gnuplot extension.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/middleman-gnuplot/extension.rb', line 20 def initialize app, ={}, &block super app.config[:gp_outdir] = .gp_outdir app.config[:gp_tmpdir] = .gp_tmpdir app.config[:gp_format] = .gp_format @@base_dir = "./#{app.config[:gp_tmpdir]}/#{app.config[:images_dir]}/" FileUtils.mkdir_p "#{@@base_dir}/#{app.config[:gp_outdir]}/" term = Middleman::Gnuplot::get_gnuplot_term(.gp_format) @@gp = Numo::Gnuplot.new @@gp.debug_on @@gp.set term:"#{term}" app.after_build do |builder| # Move generated plots to build dir FileUtils.cp_r @@base_dir, app.config[:build_dir] end end |
Instance Method Details
#plot_data(data, series = nil, filename = nil, title = nil) ⇒ Object
Generates a plot via gnuplot using the given data array The data array should be an array of rows that contains arrays of cols. e.g. [[x1, y1, z1], [x2, y2, z2], [x3, y3, z3]]
79 80 81 |
# File 'lib/middleman-gnuplot/extension.rb', line 79 def plot_data data, series=nil, filename=nil, title=nil # stub method to enable documentation in yard end |
#plot_functions(functions = [], filename = nil, title = nil) ⇒ Object
The function must be provided as hash using the following fields:
54 55 56 |
# File 'lib/middleman-gnuplot/extension.rb', line 54 def plot_functions functions=[], filename=nil, title=nil # stub method to enable documentation in yard end |
#plot_script(script, filename = nil, title = nil) ⇒ Object
Generates a plot directly from an existing gnuplot script Params:
63 64 65 |
# File 'lib/middleman-gnuplot/extension.rb', line 63 def plot_script script, filename=nil, title=nil # stub method to enable documentation in yard end |
#random_filename_if_nil(filename = nil, length = 6) ⇒ Object
87 88 89 |
# File 'lib/middleman-gnuplot/extension.rb', line 87 def random_filename_if_nil filename=nil, length=6 # stub method to enable documentation in yard end |