Class: YouPlot::Command
- Inherits:
-
Object
- Object
- YouPlot::Command
- Defined in:
- lib/youplot/command.rb
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
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 @options 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/youplot/command.rb', line 30 def run parser.(@argv) @command ||= parser.command @options ||= parser. @params ||= parser.params # color command if %i[colors color colours colour].include? @command plot = create_plot output_plot(plot) return end # progressive mode if [:progressive] stop = false Signal.trap(:INT) { stop = true } # make cursor invisible [:output].print "\e[?25l" # mainloop while (input = Kernel.gets) n = main_progressive(input) break if stop [:output].print "\e[#{n}F" end [:output].print "\e[0J" # make cursor visible [:output].print "\e[?25h" # normal mode else # Sometimes the input file does not end with a newline code. begin begin input = Kernel.gets(nil) rescue Errno::ENOENT => e warn e. next end main(input) end until input 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 |