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 29 30 31 32 |
# File 'lib/cliqr/parser/parsed_input.rb', line 24 def initialize(parsed_arguments) @command = parsed_arguments[:command] @options = Hash[parsed_arguments[:options].collect \ { |option| [option[:name].to_s, option[:value]] }]\ if parsed_arguments.key?(: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
62 63 64 |
# File 'lib/cliqr/parser/parsed_input.rb', line 62 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
69 70 71 72 73 74 75 76 |
# File 'lib/cliqr/parser/parsed_input.rb', line 69 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
53 54 55 56 57 |
# File 'lib/cliqr/parser/parsed_input.rb', line 53 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
39 40 41 |
# File 'lib/cliqr/parser/parsed_input.rb', line 39 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
46 47 48 |
# File 'lib/cliqr/parser/parsed_input.rb', line 46 def remove_option(name) @options.delete(name.to_s) end |