Class: YouPlot::Command
- Inherits:
-
Object
- Object
- YouPlot::Command
- Defined in:
- lib/youplot/command.rb,
lib/youplot/command/parser.rb,
lib/youplot/command/options.rb,
lib/youplot/command/plot_params.rb
Defined Under Namespace
Classes: Options, Parser, PlotParams
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#options ⇒ Object
Returns the value of attribute options.
-
#params ⇒ Object
Returns the value of attribute params.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize(argv = ARGV) ⇒ Command
constructor
A new instance of Command.
- #run ⇒ Object
- #run_as_executable ⇒ Object
Constructor Details
#initialize(argv = ARGV) ⇒ Command
Returns a new instance of Command.
16 17 18 19 20 21 22 23 |
# File 'lib/youplot/command.rb', line 16 def initialize(argv = ARGV) @argv = argv @parser = Parser.new @command = nil @params = nil = nil @backend = YouPlot::Backends::UnicodePlotBackend end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
13 14 15 |
# File 'lib/youplot/command.rb', line 13 def command @command end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
14 15 16 |
# File 'lib/youplot/command.rb', line 14 def data @data end |
#options ⇒ Object
Returns the value of attribute options.
13 14 15 |
# File 'lib/youplot/command.rb', line 13 def end |
#params ⇒ Object
Returns the value of attribute params.
13 14 15 |
# File 'lib/youplot/command.rb', line 13 def params @params end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
14 15 16 |
# File 'lib/youplot/command.rb', line 14 def parser @parser end |
Instance Method Details
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/youplot/command.rb', line 30 def run parser.(@argv) @command ||= parser.command ||= parser. @params ||= parser.params if i[colors color colours colour].include? @command plot = create_plot output_plot(plot) elsif [:progressive] stop = false Signal.trap(:INT) { stop = true } [:output].print "\e[?25l" # make cursor invisible while (input = Kernel.gets) n = main_progressive(input) break if stop [:output].print "\e[#{n}F" end [:output].print "\e[0J" [:output].print "\e[?25h" # make cursor visible else # Sometimes the input file does not end with a newline code. while (input = Kernel.gets(nil)) main(input) end end end |
#run_as_executable ⇒ Object
25 26 27 28 |
# File 'lib/youplot/command.rb', line 25 def run_as_executable YouPlot.run_as_executable = true run end |