Module: Rubikon::Parameter
- Included in:
- Flag, HasArguments
- Defined in:
- lib/rubikon/parameter.rb
Overview
A parameter is any command-line argument given to the application that is not prefixed with one or two dashes. Once a parameter is supplied by the user, it is relayed to the command it belongs to.
Instance Attribute Summary collapse
-
#aliases ⇒ Array<Symbol>
readonly
The alias names of this parameter.
-
#description ⇒ String
The description of this parameter.
-
#name ⇒ Symbol
readonly
The primary name of this parameter.
Instance Method Summary collapse
-
#active? ⇒ Boolean
(also: #given?)
Returns whether this parameter has is active, i.e.
-
#initialize(app, name, &block) ⇒ Object
Creates a new parameter with the given name.
Instance Attribute Details
#aliases ⇒ Array<Symbol> (readonly)
Returns The alias names of this parameter.
20 21 22 |
# File 'lib/rubikon/parameter.rb', line 20 def aliases @aliases end |
#description ⇒ String
Returns The description of this parameter.
24 25 26 |
# File 'lib/rubikon/parameter.rb', line 24 def description @description end |
#name ⇒ Symbol (readonly)
Returns The primary name of this parameter.
27 28 29 |
# File 'lib/rubikon/parameter.rb', line 27 def name @name end |
Instance Method Details
#active? ⇒ Boolean Also known as: given?
Returns whether this parameter has is active, i.e. it has been supplied by the user on the command-line
49 50 51 |
# File 'lib/rubikon/parameter.rb', line 49 def active? @active end |
#initialize(app, name, &block) ⇒ Object
Creates a new parameter with the given name
35 36 37 38 39 40 41 42 43 |
# File 'lib/rubikon/parameter.rb', line 35 def initialize(app, name, &block) raise ArgumentError unless app.is_a? Application::Base @active = false @aliases = [] @app = app @block = block @name = name.to_sym end |