Class: SlackBot::Command
- Inherits:
-
Object
- Object
- SlackBot::Command
- Defined in:
- lib/slack_bot/command.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(current_user:, params:, args:, config: nil) ⇒ Command
constructor
A new instance of Command.
- #only_direct_message? ⇒ Boolean
- #only_slack_team? ⇒ Boolean
- #only_user? ⇒ Boolean
- #render_response(response_type = nil, **kwargs) ⇒ Object
- #text ⇒ Object
Methods included from SlackBot::Concerns::ViewKlass
Methods included from SlackBot::Concerns::InteractionKlass
Constructor Details
#initialize(current_user:, params:, args:, config: nil) ⇒ Command
Returns a new instance of Command.
10 11 12 13 14 15 16 17 |
# File 'lib/slack_bot/command.rb', line 10 def initialize(current_user:, params:, args:, config: nil) @current_user = current_user @params = params @config = config || SlackBot::Config.current_instance @args = SlackBot::Args.new @args.raw_args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
9 10 11 |
# File 'lib/slack_bot/command.rb', line 9 def args @args end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/slack_bot/command.rb', line 9 def config @config end |
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
9 10 11 |
# File 'lib/slack_bot/command.rb', line 9 def current_user @current_user end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
9 10 11 |
# File 'lib/slack_bot/command.rb', line 9 def params @params end |
Instance Method Details
#command ⇒ Object
19 20 21 |
# File 'lib/slack_bot/command.rb', line 19 def command params[:command] end |
#only_direct_message? ⇒ Boolean
31 32 33 |
# File 'lib/slack_bot/command.rb', line 31 def true end |
#only_slack_team? ⇒ Boolean
35 36 37 |
# File 'lib/slack_bot/command.rb', line 35 def only_slack_team? true end |
#only_user? ⇒ Boolean
27 28 29 |
# File 'lib/slack_bot/command.rb', line 27 def only_user? true end |
#render_response(response_type = nil, **kwargs) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/slack_bot/command.rb', line 39 def render_response(response_type = nil, **kwargs) return if !response_type { response_type: response_type }.merge(kwargs) end |
#text ⇒ Object
23 24 25 |
# File 'lib/slack_bot/command.rb', line 23 def text params[:text] end |