Class: Botiasloop::Commands::Base
- Inherits:
-
Object
- Object
- Botiasloop::Commands::Base
- Defined in:
- lib/botiasloop/commands/base.rb
Overview
Base class for all slash commands Provides DSL for defining command metadata
Direct Known Subclasses
Archive, Compact, Conversations, Help, Label, New, Reset, Status, Switch, SystemPrompt, Verbose
Class Method Summary collapse
-
.command(name = nil) ⇒ Symbol?
(also: command_name)
Get or set the command name Automatically registers the command when name is set.
-
.description(text = nil) ⇒ String?
Get or set the command description.
-
.inherited(subclass) ⇒ Object
Called when a subclass is defined No-op - registration happens when command() is called.
Instance Method Summary collapse
-
#execute(context, args = nil) ⇒ String
Execute the command.
Class Method Details
.command(name = nil) ⇒ Symbol? Also known as: command_name
Get or set the command name Automatically registers the command when name is set
14 15 16 17 18 19 20 21 |
# File 'lib/botiasloop/commands/base.rb', line 14 def command(name = nil) if name @command_name = name # Auto-register when command name is set Botiasloop::Commands.registry.register(self) end @command_name end |
.description(text = nil) ⇒ String?
Get or set the command description
29 30 31 32 33 34 |
# File 'lib/botiasloop/commands/base.rb', line 29 def description(text = nil) if text @description = text end @description end |
.inherited(subclass) ⇒ Object
Called when a subclass is defined No-op - registration happens when command() is called
38 39 40 |
# File 'lib/botiasloop/commands/base.rb', line 38 def inherited(subclass) super end |
Instance Method Details
#execute(context, args = nil) ⇒ String
Execute the command
49 50 51 |
# File 'lib/botiasloop/commands/base.rb', line 49 def execute(context, args = nil) raise NotImplementedError, "Subclass must implement #execute" end |