class Slack::Message
Attributes
attachments[R]
text[RW]
Public Class Methods
new(text, attachment = nil)
click to toggle source
# File lib/slack/message.rb, line 8 def initialize(text, attachment = nil) @text = text @attachments = [] @attachments << attachment if attachment end
Public Instance Methods
add_attachment(attachment)
click to toggle source
# File lib/slack/message.rb, line 14 def add_attachment(attachment) @attachments << attachment end
as_json()
click to toggle source
# File lib/slack/message.rb, line 18 def as_json hash = { text: text } merge_attachments(hash) unless attachments.empty? hash end
Private Instance Methods
merge_attachments(hash)
click to toggle source
# File lib/slack/message.rb, line 28 def merge_attachments(hash) json = [] attachments.each do |attachment| json << attachment.as_json end hash.merge!(attachments: json) end