Class: Command
- Inherits:
-
Object
- Object
- Command
- Defined in:
- lib/nub/commander.rb
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#examples ⇒ Object
Returns the value of attribute examples.
-
#help ⇒ Object
Returns the value of attribute help.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nodes ⇒ Object
Returns the value of attribute nodes.
Instance Method Summary collapse
-
#initialize(name, desc, nodes: [], examples: nil) ⇒ Command
constructor
Create a new command.
-
#to_s(level: 0) ⇒ Object
Return a human readable string of this object.
-
#to_sym ⇒ Object
Get a symbol representing the command.
Constructor Details
#initialize(name, desc, nodes: [], examples: nil) ⇒ Command
Create a new command
113 114 115 116 117 118 119 |
# File 'lib/nub/commander.rb', line 113 def initialize(name, desc, nodes:[], examples:nil) @name = name @desc = desc @nodes = nodes @examples = examples @help = "" end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
103 104 105 |
# File 'lib/nub/commander.rb', line 103 def desc @desc end |
#examples ⇒ Object
Returns the value of attribute examples.
106 107 108 |
# File 'lib/nub/commander.rb', line 106 def examples @examples end |
#help ⇒ Object
Returns the value of attribute help.
105 106 107 |
# File 'lib/nub/commander.rb', line 105 def help @help end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
102 103 104 |
# File 'lib/nub/commander.rb', line 102 def name @name end |
#nodes ⇒ Object
Returns the value of attribute nodes.
104 105 106 |
# File 'lib/nub/commander.rb', line 104 def nodes @nodes end |
Instance Method Details
#to_s(level: 0) ⇒ Object
Return a human readable string of this object
129 130 131 132 133 134 135 |
# File 'lib/nub/commander.rb', line 129 def to_s(level:0) str = "#{" " * level * 2}Command => name:#{@name}, desc:'#{@desc}'" @nodes.each{|x| str += "\n#{x.to_s(level: level + 1)}" } return str end |
#to_sym ⇒ Object
Get a symbol representing the command
123 124 125 |
# File 'lib/nub/commander.rb', line 123 def to_sym return @name.gsub('-', '_').to_sym end |