Class: Kerplutz::Command
- Inherits:
-
Object
- Object
- Kerplutz::Command
- Extended by:
- Forwardable
- Defined in:
- lib/kerplutz/command.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
- #add_option(option, prefix_key = true) ⇒ Object
- #banner=(banner) ⇒ Object
- #display_name ⇒ Object
-
#initialize(name, desc, arguments = {}) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(name, desc, arguments = {}) ⇒ Command
Returns a new instance of Command.
10 11 12 13 14 15 |
# File 'lib/kerplutz/command.rb', line 10 def initialize(name, desc, arguments={}) @name = name @desc = desc @arguments = arguments @parser = OptionParser.new() end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
6 7 8 |
# File 'lib/kerplutz/command.rb', line 6 def arguments @arguments end |
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
6 7 8 |
# File 'lib/kerplutz/command.rb', line 6 def desc @desc end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/kerplutz/command.rb', line 6 def name @name end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
6 7 8 |
# File 'lib/kerplutz/command.rb', line 6 def parser @parser end |
Instance Method Details
#add_option(option, prefix_key = true) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kerplutz/command.rb', line 25 def add_option(option, prefix_key=true) if prefix_key key = :"#{name}_#{option.name}" else key = option.name.to_sym end option.configure(parser) do |value| arguments[key] = value end end |
#banner=(banner) ⇒ Object
21 22 23 |
# File 'lib/kerplutz/command.rb', line 21 def () parser. = (.chomp << "\n\n") end |
#display_name ⇒ Object
17 18 19 |
# File 'lib/kerplutz/command.rb', line 17 def display_name @display_name ||= name.to_s.tr("_", "-") end |