Fix variables

This commit is contained in:
kojix2 2020-09-17 10:28:01 +09:00
parent 975eb95f55
commit b6c3ca9b43
2 changed files with 11 additions and 7 deletions

View File

@ -14,9 +14,6 @@ module Uplot
@params = Params.new @params = Params.new
@command = nil @command = nil
@headers = nil
@delimiter = "\t"
@transpose = false
@output = false @output = false
@count = false @count = false
@fmt = 'xyy' @fmt = 'xyy'
@ -32,6 +29,9 @@ module Uplot
parser.parse_options parser.parse_options
command = parser.command command = parser.command
params = parser.params params = parser.params
delimiter = parser.delimiter
transpose = parser.transpose
headers = parser.headers
if command == :colors if command == :colors
Plot.colors Plot.colors
@ -42,7 +42,7 @@ module Uplot
while input = Kernel.gets(nil) while input = Kernel.gets(nil)
input.freeze input.freeze
@raw_inputs << input @raw_inputs << input
@data = Preprocessing.input(input, @delimiter, @headers, @transpose) @data = Preprocessing.input(input, delimiter, headers, transpose)
pp @data if @debug pp @data if @debug
case command case command
when :bar, :barplot when :bar, :barplot

View File

@ -1,14 +1,18 @@
module Uplot module Uplot
class Command class Command
class Parser class Parser
attr_reader :command, :params, :main_parser, :sub_parsers attr_reader :command, :params, :main_parser, :sub_parsers, :delimiter, :transpose, :headers
def initialize def initialize
@sub_parsers = create_sub_parsers @sub_parsers = create_sub_parsers
@main_parser = create_main_parser @main_parser = create_main_parser
@command = nil @command = nil
@params = Params.new @params = Params.new
end
@delimiter = "\t"
@transpose = false
@headers = nil
end
def create_default_parser def create_default_parser
OptionParser.new do |opt| OptionParser.new do |opt|
@ -51,7 +55,7 @@ module Uplot
params.padding = v params.padding = v
end end
opt.on('-c', '--color VAL', 'color of the drawing', String) do |v| opt.on('-c', '--color VAL', 'color of the drawing', String) do |v|
params.color = v =~ /\A[0-9]+\z/ ? v.to_i : v.to_sym params.color = v =~ /\<[0-9]+\>/ ? v.to_i : v.to_sym
end end
opt.on('--[no-]labels', 'hide the labels', TrueClass) do |v| opt.on('--[no-]labels', 'hide the labels', TrueClass) do |v|
params.labels = v params.labels = v