Class: Excavator::Param
- Inherits:
-
Object
- Object
- Excavator::Param
- Defined in:
- lib/excavator/param.rb
Overview
Internal: Param is an object to describe the attributes of a parameter. There’s never a need to instantiate these directly - instead use DSL#param.
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Public: An optional default value for the Param.
-
#desc ⇒ Object
readonly
Public: An optional String description for the Param.
-
#name ⇒ Object
readonly
Public: The String/Symbol name of the Param.
-
#short ⇒ Object
Public: An optional String (normally one character) to use as the short switch for the Param.
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ Param
constructor
A new instance of Param.
-
#optional? ⇒ Boolean
Public: Returns whether or not the Param is optional.
-
#required? ⇒ Boolean
Public: Returns whether or not the Param is required.
Constructor Details
#initialize(name, options = {}) ⇒ Param
Returns a new instance of Param.
22 23 24 25 26 27 28 |
# File 'lib/excavator/param.rb', line 22 def initialize(name, = {}) @name = name @default = [:default] @optional = [:optional] @desc = [:desc] @short = [:short] end |
Instance Attribute Details
#default ⇒ Object (readonly)
Public: An optional default value for the Param.
13 14 15 |
# File 'lib/excavator/param.rb', line 13 def default @default end |
#desc ⇒ Object (readonly)
Public: An optional String description for the Param.
16 17 18 |
# File 'lib/excavator/param.rb', line 16 def desc @desc end |
#name ⇒ Object (readonly)
Public: The String/Symbol name of the Param.
10 11 12 |
# File 'lib/excavator/param.rb', line 10 def name @name end |
#short ⇒ Object
Public: An optional String (normally one character) to use as the short switch for the Param.
20 21 22 |
# File 'lib/excavator/param.rb', line 20 def short @short end |
Instance Method Details
#optional? ⇒ Boolean
Public: Returns whether or not the Param is optional.
Returns a Boolean.
40 41 42 |
# File 'lib/excavator/param.rb', line 40 def optional? @default || (@default.nil? && @optional) end |
#required? ⇒ Boolean
Public: Returns whether or not the Param is required.
Returns a Boolean.
33 34 35 |
# File 'lib/excavator/param.rb', line 33 def required? !optional? end |