Class: Cliqr::Parser::ParsedInput Private
- Inherits:
-
Object
- Object
- Cliqr::Parser::ParsedInput
- Defined in:
- lib/cliqr/parser/parsed_input.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A wrapper to keep the parsed input arguments
Instance Attribute Summary collapse
-
#arguments ⇒ Array<String>
private
List of arguments from the command line.
-
#command ⇒ String
private
Command name.
-
#options ⇒ Hash
private
Hash of options parsed from the command line.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
private
Test equality with another object.
-
#default_action(action_config) ⇒ Symbol
private
Get name of default action if present as option.
-
#eql?(other) ⇒ Boolean
private
Test equality with another object.
-
#initialize(parsed_arguments) ⇒ ParsedInput
constructor
private
Initialize a new parsed input.
-
#option(name) ⇒ String
private
Get a value of an option.
-
#remove_option(name) ⇒ Object
private
Remove a option.
Constructor Details
#initialize(parsed_arguments) ⇒ ParsedInput
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a new parsed input
24 25 26 27 28 |
# File 'lib/cliqr/parser/parsed_input.rb', line 24 def initialize(parsed_arguments) @command = parsed_arguments[:command] @options = parsed_arguments[:options] @arguments = parsed_arguments[:arguments] end |
Instance Attribute Details
#arguments ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
List of arguments from the command line
21 22 23 |
# File 'lib/cliqr/parser/parsed_input.rb', line 21 def arguments @arguments end |
#command ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Command name
11 12 13 |
# File 'lib/cliqr/parser/parsed_input.rb', line 11 def command @command end |
#options ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Hash of options parsed from the command line
16 17 18 |
# File 'lib/cliqr/parser/parsed_input.rb', line 16 def @options end |
Instance Method Details
#==(other) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Test equality with another object
58 59 60 |
# File 'lib/cliqr/parser/parsed_input.rb', line 58 def ==(other) eql?(other) end |
#default_action(action_config) ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get name of default action if present as option
65 66 67 68 69 70 71 72 |
# File 'lib/cliqr/parser/parsed_input.rb', line 65 def default_action(action_config) if option('help') && action_config.help? return :help elsif option('version') && action_config.version? return :version end nil end |
#eql?(other) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Test equality with another object
49 50 51 52 53 |
# File 'lib/cliqr/parser/parsed_input.rb', line 49 def eql?(other) self.class.equal?(other.class) && @command == other.command && @options == other. end |
#option(name) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get a value of an option
35 36 37 |
# File 'lib/cliqr/parser/parsed_input.rb', line 35 def option(name) @options[name.to_s] end |
#remove_option(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Remove a option
42 43 44 |
# File 'lib/cliqr/parser/parsed_input.rb', line 42 def remove_option(name) @options.delete(name.to_s) end |