Class: Bane::ArgumentsParser
- Inherits:
-
Object
- Object
- Bane::ArgumentsParser
- Defined in:
- lib/bane/arguments_parser.rb
Instance Method Summary collapse
-
#initialize(makeable_names) ⇒ ArgumentsParser
constructor
A new instance of ArgumentsParser.
- #parse(args) ⇒ Object
- #usage ⇒ Object
Constructor Details
#initialize(makeable_names) ⇒ ArgumentsParser
Returns a new instance of ArgumentsParser.
5 6 7 8 9 |
# File 'lib/bane/arguments_parser.rb', line 5 def initialize(makeable_names) @makeable_names = makeable_names @options = {host: default_host} @option_parser = init_option_parser end |
Instance Method Details
#parse(args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bane/arguments_parser.rb', line 11 def parse(args) @option_parser.parse!(args) raise ConfigurationError, "Missing arguments" if args.empty? port = parse_port(args[0]) behaviors = args.drop(1) ParsedArguments.new(port, @options[:host], behaviors) rescue OptionParser::InvalidOption => io raise ConfigurationError, io. end |
#usage ⇒ Object
23 24 25 |
# File 'lib/bane/arguments_parser.rb', line 23 def usage @option_parser.help end |