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_functions(functions = [], filename = nil, title = nil) ⇒ Object
Generates a plot via gnuplot using a given expression.
-
#plot_script(script, filename = nil, title = nil) ⇒ Object
Generates a plot directly from an existing gnuplot script Params:.
-
#random_filename_if_nil(filename = nil) ⇒ Object
Generates a random filename, if the given paramter is nil or empty Returns filename (given or random) Params.
Constructor Details
#initialize(app, options_hash = {}, &block) ⇒ GnuplotExtension
Initializes the middleman-gnuplot extension.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/middleman-gnuplot/extension.rb', line 19 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_functions(functions = [], filename = nil, title = nil) ⇒ Object
Generates a plot via gnuplot using a given expression. The function must be provided as hash using the following fields:
50 51 52 |
# File 'lib/middleman-gnuplot/extension.rb', line 50 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:
59 60 61 |
# File 'lib/middleman-gnuplot/extension.rb', line 59 def plot_script (script, filename=nil, title=nil) # stub method to enable documentation in yard end |
#random_filename_if_nil(filename = nil) ⇒ Object
Generates a random filename, if the given paramter is nil or empty Returns filename (given or random) Params.
filename-
input filename
67 68 69 |
# File 'lib/middleman-gnuplot/extension.rb', line 67 def random_filename_if_nil (filename=nil) # stub method to enable documentation in yard end |