Class: Abt::Cli::ArgumentsParser
- Inherits:
-
Object
- Object
- Abt::Cli::ArgumentsParser
- Defined in:
- lib/abt/cli/arguments_parser.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
Instance Method Summary collapse
-
#initialize(arguments) ⇒ ArgumentsParser
constructor
A new instance of ArgumentsParser.
- #parse ⇒ Object
Constructor Details
#initialize(arguments) ⇒ ArgumentsParser
Returns a new instance of ArgumentsParser.
8 9 10 |
# File 'lib/abt/cli/arguments_parser.rb', line 8 def initialize(arguments) @arguments = arguments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
6 7 8 |
# File 'lib/abt/cli/arguments_parser.rb', line 6 def arguments @arguments end |
Instance Method Details
#parse ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/abt/cli/arguments_parser.rb', line 12 def parse result = AriList.new rest = arguments.dup # If the first arg is a flag, it's for a global command result << Ari.new(flags: take_flags(rest)) if flag?(rest.first) until rest.empty? (scheme, path) = rest.shift.split(":") flags = take_flags(rest) result << Ari.new(scheme: scheme, path: path, flags: flags) end result end |