Module: GnuplotRB::Settings
- Defined in:
- lib/gnuplotrb/staff/settings.rb
Overview
This module takes care of path to gnuplot executable and checking its version.
Constant Summary collapse
- MIN_GNUPLOT_VERSION =
GnuplotRB can work with Gnuplot 5.0+
5.0
Class Attribute Summary collapse
-
.max_fit_delay ⇒ Integer
Get max fit delay.
Class Method Summary collapse
-
.available_terminals ⇒ Array of String
Get list of terminals (png, html, qt, jpeg etc) available for this gnuplot.
-
.gnuplot_path ⇒ String
Get path that should be used to run gnuplot executable.
-
.gnuplot_path=(path) ⇒ Object
Set path to gnuplot executable.
-
.validate_version(path) ⇒ Object
Validate gnuplot version.
-
.version ⇒ Numeric
Get gnuplot version.
Class Attribute Details
.max_fit_delay ⇒ Integer
Get max fit delay.
Max fit delay (5s by default) is used inside Fit::fit function. If it waits for output more than max_fit_delay seconds this behaviour is considered as errorneus.
20 21 22 |
# File 'lib/gnuplotrb/staff/settings.rb', line 20 def max_fit_delay @max_fit_delay ||= 5 end |
Class Method Details
.available_terminals ⇒ Array of String
Get list of terminals (png, html, qt, jpeg etc) available for this gnuplot.
50 51 52 53 |
# File 'lib/gnuplotrb/staff/settings.rb', line 50 def available_terminals gnuplot_path @available_terminals end |
.gnuplot_path ⇒ String
Get path that should be used to run gnuplot executable. Default value: ‘gnuplot’.
28 29 30 31 |
# File 'lib/gnuplotrb/staff/settings.rb', line 28 def gnuplot_path self.gnuplot_path = 'gnuplot' unless defined?(@gnuplot_path) @gnuplot_path end |
.gnuplot_path=(path) ⇒ Object
Set path to gnuplot executable.
37 38 39 40 41 42 43 44 45 |
# File 'lib/gnuplotrb/staff/settings.rb', line 37 def gnuplot_path=(path) validate_version(path) opts = { stdin_data: "set term\n" } @available_terminals = Open3.capture2e(path, **opts) .first .scan(/[:\n] +([a-z][^ ]+)/) .map(&:first) @gnuplot_path = path end |
.validate_version(path) ⇒ Object
Validate gnuplot version. Compares current gnuplot’s version with ::MIN_GNUPLOT_VERSION. Throws exception if version is less than min.
70 71 72 73 74 75 76 77 |
# File 'lib/gnuplotrb/staff/settings.rb', line 70 def validate_version(path) @version = IO.popen("#{path} --version") .read .match(/gnuplot ([^ ]+)/)[1] .to_f = "Your Gnuplot version is #{@version}, please update it to at least 5.0" fail(ArgumentError, ) if @version < MIN_GNUPLOT_VERSION end |
.version ⇒ Numeric
Get gnuplot version. Uses gnuplot_path to find gnuplot executable.
58 59 60 61 |
# File 'lib/gnuplotrb/staff/settings.rb', line 58 def version gnuplot_path @version end |