diff --git a/lib/youplot.rb b/lib/youplot.rb index d7bcd80..9e8e6b0 100644 --- a/lib/youplot.rb +++ b/lib/youplot.rb @@ -3,6 +3,7 @@ require 'unicode_plot' require 'youplot/version' require 'youplot/dsv' +require 'youplot/parameters' require 'youplot/command' module YouPlot diff --git a/lib/youplot/command/parser.rb b/lib/youplot/command/parser.rb index 0a50e9c..7c128cb 100644 --- a/lib/youplot/command/parser.rb +++ b/lib/youplot/command/parser.rb @@ -2,7 +2,6 @@ require 'optparse' require_relative 'options' -require_relative 'plot_params' module YouPlot class Command @@ -28,7 +27,7 @@ module YouPlot debug: false ) - @params = PlotParams.new + @params = Parameters.new end def create_default_parser diff --git a/lib/youplot/command/plot_params.rb b/lib/youplot/command/plot_params.rb deleted file mode 100644 index 2f85592..0000000 --- a/lib/youplot/command/plot_params.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -module YouPlot - class Command - # UnicodePlot parameters. - # * Normally in a Ruby program, you might use hash for the parameter object. - # * Here, I use Struct for 2 safety reason. - # * The keys are static in Struct. - # * Struct does not conflict with keyword arguments. Hash dose. - PlotParams = Struct.new( - # Sort me! - :title, - :width, - :height, - :border, - :margin, - :padding, - :color, - :xlabel, - :ylabel, - :labels, - :symbol, - :xscale, - :nbins, - :closed, - :canvas, - :xlim, - :ylim, - :grid, - :name - ) do - def to_hc - to_h.compact - end - end - end -end diff --git a/lib/youplot/parameters.rb b/lib/youplot/parameters.rb new file mode 100644 index 0000000..4c35b4b --- /dev/null +++ b/lib/youplot/parameters.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module YouPlot + # UnicodePlot parameters. + # * Normally in a Ruby program, you might use hash for the parameter object. + # * Here, I use Struct for 2 safety reason. + # * The keys are static in Struct. + # * Struct does not conflict with keyword arguments. Hash dose. + Parameters = Struct.new( + # Sort me! + :title, + :width, + :height, + :border, + :margin, + :padding, + :color, + :xlabel, + :ylabel, + :labels, + :symbol, + :xscale, + :nbins, + :closed, + :canvas, + :xlim, + :ylim, + :grid, + :name + ) do + def to_hc + to_h.compact + end + end +end