Class: Clamp::Subcommand
- Inherits:
-
Struct
- Object
- Struct
- Clamp::Subcommand
- Defined in:
- lib/clamp/subcommand.rb,
lib/clamp/subcommand/parsing.rb,
lib/clamp/subcommand/declaration.rb
Defined Under Namespace
Modules: Declaration, Parsing
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ Object
Returns the value of attribute name.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#subcommand_class ⇒ Object
Returns the value of attribute subcommand_class.
Instance Method Summary collapse
- #help ⇒ Object
-
#initialize(names, description, subcommand_class) ⇒ Subcommand
constructor
A new instance of Subcommand.
- #is_called?(name) ⇒ Boolean
Constructor Details
#initialize(names, description, subcommand_class) ⇒ Subcommand
Returns a new instance of Subcommand.
5 6 7 8 9 |
# File 'lib/clamp/subcommand.rb', line 5 def initialize(names, description, subcommand_class) @names = Array(names) @description = description @subcommand_class = subcommand_class end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description
3 4 5 |
# File 'lib/clamp/subcommand.rb', line 3 def description @description end |
#name ⇒ Object
Returns the value of attribute name
3 4 5 |
# File 'lib/clamp/subcommand.rb', line 3 def name @name end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
11 12 13 |
# File 'lib/clamp/subcommand.rb', line 11 def names @names end |
#subcommand_class ⇒ Object
Returns the value of attribute subcommand_class
3 4 5 |
# File 'lib/clamp/subcommand.rb', line 3 def subcommand_class @subcommand_class end |
Instance Method Details
#help ⇒ Object
17 18 19 |
# File 'lib/clamp/subcommand.rb', line 17 def help [names.join(", "), description] end |
#is_called?(name) ⇒ Boolean
13 14 15 |
# File 'lib/clamp/subcommand.rb', line 13 def is_called?(name) names.member?(name) end |