Class: Pyer::Option
- Inherits:
-
Object
- Object
- Pyer::Option
- Defined in:
- lib/pyer/options.rb
Overview
Option class
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#expects_argument ⇒ Object
readonly
Returns the value of attribute expects_argument.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#short ⇒ Object
readonly
Returns the value of attribute short.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, description, &block) ⇒ Option
constructor
Incapsulate internal option information, mainly used to store option specific configuration data.
Constructor Details
#initialize(name, description, &block) ⇒ Option
Incapsulate internal option information, mainly used to store option specific configuration data.
name - The String or Symbol option name. description - The String description text. block - An optional block.
289 290 291 292 293 294 295 296 297 298 |
# File 'lib/pyer/options.rb', line 289 def initialize(name, description, &block) # Remove leading '-' from name if any @name = name.to_s.gsub(/^--?/, '') fail InvalidOptionError, "Option #{@name} is invalid" if @name.size < 2 @expects_argument = false @value = nil @short = @name[0] @description = description @callback = (block_given? ? block : nil) end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
279 280 281 |
# File 'lib/pyer/options.rb', line 279 def callback @callback end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
279 280 281 |
# File 'lib/pyer/options.rb', line 279 def description @description end |
#expects_argument ⇒ Object (readonly)
Returns the value of attribute expects_argument.
280 281 282 |
# File 'lib/pyer/options.rb', line 280 def expects_argument @expects_argument end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
279 280 281 |
# File 'lib/pyer/options.rb', line 279 def name @name end |
#short ⇒ Object (readonly)
Returns the value of attribute short.
279 280 281 |
# File 'lib/pyer/options.rb', line 279 def short @short end |
#value ⇒ Object
Returns the value of attribute value.
281 282 283 |
# File 'lib/pyer/options.rb', line 281 def value @value end |