Class: Kerplutz::Option
- Inherits:
-
Object
- Object
- Kerplutz::Option
- Defined in:
- lib/kerplutz/options.rb
Instance Attribute Summary collapse
-
#abbrev ⇒ Object
Returns the value of attribute abbrev.
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #abbrev_sig ⇒ Object
- #configure(parser, &blk) ⇒ Object
- #display_name ⇒ Object
-
#initialize(name, desc) ⇒ Option
constructor
A new instance of Option.
- #option_sig ⇒ Object
- #parser_args ⇒ Object
Constructor Details
#initialize(name, desc) ⇒ Option
Returns a new instance of Option.
12 13 14 15 |
# File 'lib/kerplutz/options.rb', line 12 def initialize(name, desc) @name = name @desc = desc end |
Instance Attribute Details
#abbrev ⇒ Object
Returns the value of attribute abbrev.
4 5 6 |
# File 'lib/kerplutz/options.rb', line 4 def abbrev @abbrev end |
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
3 4 5 |
# File 'lib/kerplutz/options.rb', line 3 def desc @desc end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/kerplutz/options.rb', line 3 def name @name end |
Class Method Details
.build(name, desc, opts) ⇒ Object
6 7 8 9 10 |
# File 'lib/kerplutz/options.rb', line 6 def self.build(name, desc, opts) option = self.new(name, desc) option.abbrev = opts[:abbrev] option end |
Instance Method Details
#abbrev_sig ⇒ Object
25 26 27 |
# File 'lib/kerplutz/options.rb', line 25 def abbrev_sig return "-#{abbrev[0]}" if abbrev end |
#configure(parser, &blk) ⇒ Object
33 34 35 |
# File 'lib/kerplutz/options.rb', line 33 def configure(parser, &blk) raise "You'll need to implement this one yourself, bub." end |
#display_name ⇒ Object
17 18 19 |
# File 'lib/kerplutz/options.rb', line 17 def display_name name.to_s.tr("_", "-") end |
#option_sig ⇒ Object
21 22 23 |
# File 'lib/kerplutz/options.rb', line 21 def option_sig "--#{display_name}" end |
#parser_args ⇒ Object
29 30 31 |
# File 'lib/kerplutz/options.rb', line 29 def parser_args [abbrev_sig, option_sig, desc].compact end |