Class: BotBrain::Commands::Command
- Inherits:
-
Object
- Object
- BotBrain::Commands::Command
- Defined in:
- lib/bot_brain/commands/command.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #answer(message) ⇒ Object
- #can_answer?(message) ⇒ Boolean
- #help ⇒ Object
-
#initialize(name) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(name) ⇒ Command
Returns a new instance of Command.
6 7 8 9 |
# File 'lib/bot_brain/commands/command.rb', line 6 def initialize(name) @name = name @alias = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/bot_brain/commands/command.rb', line 4 def name @name end |
Instance Method Details
#answer(message) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/bot_brain/commands/command.rb', line 16 def answer() @args = parse_args(.text) return help_full if @args == '?' process() end |
#can_answer?(message) ⇒ Boolean
11 12 13 14 |
# File 'lib/bot_brain/commands/command.rb', line 11 def can_answer?() data = name_regexp.match(.text) !!data && data.length > 0 end |
#help ⇒ Object
23 24 25 |
# File 'lib/bot_brain/commands/command.rb', line 23 def help "#{name} - #{description}\n" end |