Class: ShellOpts::Option
- Inherits:
-
Object
- Object
- ShellOpts::Option
- Defined in:
- lib/shellopts/option.rb,
lib/shellopts/dump.rb
Overview
Option models an option as given by the user on the subcommand line. Compiled options (and possibly aggregated) options are stored in the Command#option_values array
Instance Attribute Summary collapse
-
#argument ⇒ Object
Argument value or nil if not present.
-
#grammar ⇒ Object
readonly
Associated Grammar::Option object.
-
#name ⇒ Object
readonly
The actual name used on the shell command-line (String).
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(grammar, name, argument) ⇒ Option
constructor
A new instance of Option.
Constructor Details
#initialize(grammar, name, argument) ⇒ Option
Returns a new instance of Option.
23 24 25 |
# File 'lib/shellopts/option.rb', line 23 def initialize(grammar, name, argument) @grammar, @name, @argument = grammar, name, argument end |
Instance Attribute Details
#argument ⇒ Object
Argument value or nil if not present. The value is a String, Integer, or Float depending the on the type of the option
14 15 16 |
# File 'lib/shellopts/option.rb', line 14 def argument @argument end |
#grammar ⇒ Object (readonly)
Associated Grammar::Option object
7 8 9 |
# File 'lib/shellopts/option.rb', line 7 def grammar @grammar end |
#name ⇒ Object (readonly)
The actual name used on the shell command-line (String)
10 11 12 |
# File 'lib/shellopts/option.rb', line 10 def name @name end |
Instance Method Details
#dump ⇒ Object
153 154 155 |
# File 'lib/shellopts/dump.rb', line 153 def dump ::Kernel.puts [name, argument].compact.join(" ") end |