Class: Slackathon::Command
- Inherits:
-
Object
- Object
- Slackathon::Command
- Defined in:
- lib/slackathon/command.rb
Class Method Summary collapse
- .dispatch_command(params) ⇒ Object
- .dispatch_interaction(params) ⇒ Object
- .unescape(message) ⇒ Object
Instance Method Summary collapse
-
#initialize(params) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(params) ⇒ Command
Returns a new instance of Command.
25 26 27 |
# File 'lib/slackathon/command.rb', line 25 def initialize(params) @params = params end |
Class Method Details
.dispatch_command(params) ⇒ Object
3 4 5 |
# File 'lib/slackathon/command.rb', line 3 def self.dispatch_command(params) self.new(params).call end |
.dispatch_interaction(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/slackathon/command.rb', line 7 def self.dispatch_interaction(params) action = params[:actions][0] method = self.new(params).public_method(action[:name]) value = action[:value] if method.arity == 0 method.call else method.call(self.unescape(value)) end end |
.unescape(message) ⇒ Object
19 20 21 22 23 |
# File 'lib/slackathon/command.rb', line 19 def self.unescape() .gsub(/&/, "&") .gsub(/</, "<") .gsub(/>/, ">") end |