class Plasper::Options
Constants
- DEFAULT_ACTION
- VALID_ACTIONS
Attributes
action[R]
output_file[R]
text_file[R]
weights_file[R]
Public Class Methods
new(argv)
click to toggle source
Initialize with CLI arguments
@param [Array] argv
# File lib/Plasper/options.rb, line 13 def initialize(argv) parse argv @action = argv.last @action = DEFAULT_ACTION unless VALID_ACTIONS.include? @action end
Private Instance Methods
assign_output_file(options)
click to toggle source
Assign output file path from options
@param [OptionParser] options
# File lib/Plasper/options.rb, line 61 def assign_output_file(options) options.on('-o', '--output-file path', String, 'Path to output file for dumping weights') do |path| @output_file = path end end
assign_text_file(options)
click to toggle source
Assign input text file path from options
@param [OptionParser] options
# File lib/Plasper/options.rb, line 43 def assign_text_file(options) options.on('-t', '--text-file path', String, 'Path to file with text to analyze') do |path| @text_file = path end end
assign_weights_file(options)
click to toggle source
Assign input weights file path from options
@param [OptionParser] options
# File lib/Plasper/options.rb, line 52 def assign_weights_file(options) options.on('-w', '--weights-file path', String, 'Path to file with initial weights in YAML format') do |path| @weights_file = path end end
parse(argv)
click to toggle source
Parse given arguments
@param [Array] argv
# File lib/Plasper/options.rb, line 24 def parse(argv) OptionParser.new do |options| usage_and_help options assign_text_file options assign_weights_file options assign_output_file options begin options.parse argv rescue OptionParser::ParseError => error STDERR.puts error.message, "\n", options exit(-1) end end end
usage_and_help(options)
click to toggle source
Chunk with usage information and help
@param [OptionParser] options
# File lib/Plasper/options.rb, line 70 def usage_and_help(options) options.banner = "Usage: plasper [options] action\n action: dump (default), talk or chat" options.on('-h', '--help', 'Show this message') do puts options exit end end