Class: Slackdraft::Attachment
Instance Method Summary collapse
-
#add_field(title, value, short = true) ⇒ Object
Short defines if it’s 1 column or not, default: not.
-
#generate_payload ⇒ Object
Generate the payload for slack attachments.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Slackdraft::Base
Instance Method Details
#add_field(title, value, short = true) ⇒ Object
Short defines if it’s 1 column or not, default: not
22 23 24 |
# File 'lib/slackdraft/attachment.rb', line 22 def add_field(title, value, short=true) fields.push({:title => title, :value => value, :short => short }) end |
#generate_payload ⇒ Object
Generate the payload for slack attachments
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/slackdraft/attachment.rb', line 27 def generate_payload payload = {} payload[:fallback] = self.fallback unless self.fallback.nil? payload[:color] = self.color unless self.color.nil? payload[:pretext] = self.pretext unless self.pretext.nil? payload[:author_name] = self. unless self..nil? payload[:author_link] = self. unless self..nil? payload[:author_icon] = self. unless self..nil? payload[:title] = self.title unless self.title.nil? payload[:title_link] = self.title_link unless self.title_link.nil? payload[:text] = self.text unless self.text.nil? unless self.fields.nil? payload[:fields] = self.fields if self.fields.length > 0 end payload[:image_url] = self.image_url unless self.image_url.nil? puts payload.inspect payload end |