Class: RoboPigeon::Slack::Message
- Inherits:
-
Object
- Object
- RoboPigeon::Slack::Message
- Defined in:
- lib/robopigeon/slack/message.rb
Instance Attribute Summary collapse
-
#attachments ⇒ Object
Returns the value of attribute attachments.
-
#channels ⇒ Object
Returns the value of attribute channels.
-
#text ⇒ Object
Returns the value of attribute text.
-
#users ⇒ Object
Returns the value of attribute users.
Instance Method Summary collapse
- #client ⇒ Object
-
#initialize ⇒ Message
constructor
A new instance of Message.
- #send! ⇒ Object
- #send_message(recipient) ⇒ Object
Constructor Details
#initialize ⇒ Message
Returns a new instance of Message.
4 5 6 7 8 |
# File 'lib/robopigeon/slack/message.rb', line 4 def initialize self. = [] self.users = [] self.channels = [] end |
Instance Attribute Details
#attachments ⇒ Object
Returns the value of attribute attachments.
3 4 5 |
# File 'lib/robopigeon/slack/message.rb', line 3 def @attachments end |
#channels ⇒ Object
Returns the value of attribute channels.
3 4 5 |
# File 'lib/robopigeon/slack/message.rb', line 3 def channels @channels end |
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/robopigeon/slack/message.rb', line 3 def text @text end |
#users ⇒ Object
Returns the value of attribute users.
3 4 5 |
# File 'lib/robopigeon/slack/message.rb', line 3 def users @users end |
Instance Method Details
#client ⇒ Object
10 11 12 |
# File 'lib/robopigeon/slack/message.rb', line 10 def client RoboPigeon::Slack::Client end |
#send! ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/robopigeon/slack/message.rb', line 26 def send! users.reject(&:nil?).each do |user| (user) end channels.reject(&:nil?).each do |channel| (channel) end end |
#send_message(recipient) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/robopigeon/slack/message.rb', line 14 def (recipient) raise 'No text or attachments set' if (text.nil? || text.empty?) && .empty? client.client.chat_postMessage( channel: recipient, text: text, icon_emoji: client.emoji, username: client.name, attachments: ) end |