Class: Sinatra::Slack::Helpers::SlackResponse
- Inherits:
-
Object
- Object
- Sinatra::Slack::Helpers::SlackResponse
- Defined in:
- lib/sinatra/slack/helpers/slack_response.rb
Overview
Represents a message sent to the Slack Channel.
Instance Attribute Summary collapse
-
#mrkdwn ⇒ Object
Returns the value of attribute mrkdwn.
-
#replace_original ⇒ Object
Returns the value of attribute replace_original.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #attachment {|attachment| ... } ⇒ Object
-
#initialize(callback_id) ⇒ SlackResponse
constructor
A new instance of SlackResponse.
- #to_json ⇒ Object
Constructor Details
#initialize(callback_id) ⇒ SlackResponse
Returns a new instance of SlackResponse.
12 13 14 15 16 17 18 |
# File 'lib/sinatra/slack/helpers/slack_response.rb', line 12 def initialize(callback_id) @callback_id = callback_id @text = nil = [] @replace_original = true @mrkdwn = false end |
Instance Attribute Details
#mrkdwn ⇒ Object
Returns the value of attribute mrkdwn.
10 11 12 |
# File 'lib/sinatra/slack/helpers/slack_response.rb', line 10 def mrkdwn @mrkdwn end |
#replace_original ⇒ Object
Returns the value of attribute replace_original.
10 11 12 |
# File 'lib/sinatra/slack/helpers/slack_response.rb', line 10 def replace_original @replace_original end |
#text ⇒ Object
Returns the value of attribute text.
10 11 12 |
# File 'lib/sinatra/slack/helpers/slack_response.rb', line 10 def text @text end |
Instance Method Details
#attachment {|attachment| ... } ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/sinatra/slack/helpers/slack_response.rb', line 20 def return unless block_given? = Helpers::Attachment.new(@callback_id) yield << end |
#to_json ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sinatra/slack/helpers/slack_response.rb', line 28 def to_json response = {} response[:text] = @text if @text response[:mrkdwn] = @mrkdwn response[:replace_original] = @replace_original response[:attachments] = .map(&:to_json) unless .empty? response.to_json end |