Class: BubBot::Slack::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/bub_bot/slack/command.rb

Direct Known Subclasses

Claim, Deploy, Echo, List, Release

Defined Under Namespace

Classes: Claim, Deploy, Echo, List, Release

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Command

Returns a new instance of Command.



15
16
17
18
# File 'lib/bub_bot/slack/command.rb', line 15

def initialize(options)
  @options = options
  puts "initialized a command"
end

Class Method Details

.aliasesObject



10
11
12
13
# File 'lib/bub_bot/slack/command.rb', line 10

def self.aliases
  # Guess the command name from the class name
  [self.name.demodulize.downcase]
end

.can_handle?(command) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/bub_bot/slack/command.rb', line 6

def self.can_handle?(command)
  aliases.include?(command)
end

Instance Method Details

#runObject



20
21
22
23
# File 'lib/bub_bot/slack/command.rb', line 20

def run
  name = self.class.name
  raise "Your command #{name} needs to implement 'run'"
end