Class: Slackdraft::Message
Instance Method Summary collapse
-
#channel ⇒ Object
Set the destination channel.
-
#generate_payload ⇒ Object
Generate the payload if stuff was provided.
-
#icon_emoji ⇒ Object
Set the emoji.
-
#icon_url ⇒ Object
Set the icon URL and default to the emoji.
- #refchannel(channel) ⇒ Object
- #refuser(user) ⇒ Object
-
#text ⇒ Object
Set the text of the message.
-
#username ⇒ Object
Set the api call username.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Slackdraft::Base
Instance Method Details
#channel ⇒ Object
Set the destination channel
18 19 20 21 |
# File 'lib/slackdraft/message.rb', line 18 def channel return '#general' if @channel.nil? @channel end |
#generate_payload ⇒ Object
Generate the payload if stuff was provided
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/slackdraft/message.rb', line 53 def generate_payload payload = {} payload[:channel] = self.channel unless self.channel.nil? payload[:username] = self.username unless self.username.nil? payload[:icon_url] = self.icon_url unless self.icon_url.nil? payload[:icon_emoji] = self.icon_emoji unless self.icon_emoji.nil? payload[:text] = self.text unless self.text.nil? payload end |
#icon_emoji ⇒ Object
Set the emoji
29 30 31 |
# File 'lib/slackdraft/message.rb', line 29 def icon_emoji return ':fire:' if @icon_emoji.nil? end |
#icon_url ⇒ Object
Set the icon URL and default to the emoji
24 25 26 |
# File 'lib/slackdraft/message.rb', line 24 def icon_url @icon_url || icon_emoji end |
#refchannel(channel) ⇒ Object
33 34 35 |
# File 'lib/slackdraft/message.rb', line 33 def refchannel(channel) "<#C024BE7LR|#{channel}>" end |
#refuser(user) ⇒ Object
37 38 39 |
# File 'lib/slackdraft/message.rb', line 37 def refuser(user) "<@U024BE7LH|#{user}>" end |
#text ⇒ Object
Set the text of the message
42 43 44 45 46 47 48 49 50 |
# File 'lib/slackdraft/message.rb', line 42 def text if @text.kind_of?(Array) return @text.join("\n") end @text end |
#username ⇒ Object
Set the api call username
12 13 14 15 |
# File 'lib/slackdraft/message.rb', line 12 def username return 'slackdraft' if @username.nil? @username end |