Class: SlackMessaging::NotifySlack
- Inherits:
-
Object
- Object
- SlackMessaging::NotifySlack
- Defined in:
- lib/slack_messaging/notify_slack.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#icon_emoji ⇒ Object
Returns the value of attribute icon_emoji.
-
#icon_url ⇒ Object
Returns the value of attribute icon_url.
-
#text ⇒ Object
Returns the value of attribute text.
-
#username ⇒ Object
Returns the value of attribute username.
-
#webhook_url ⇒ Object
Returns the value of attribute webhook_url.
Instance Method Summary collapse
-
#initialize(text) ⇒ NotifySlack
constructor
A new instance of NotifySlack.
- #perform ⇒ Object
Constructor Details
#initialize(text) ⇒ NotifySlack
Returns a new instance of NotifySlack.
5 6 7 8 9 10 11 |
# File 'lib/slack_messaging/notify_slack.rb', line 5 def initialize(text) self.text = text self.channel = SlackMessaging::Config.slack[:channel] self.webhook_url = SlackMessaging::Config.slack[:webhook_url] self.username = SlackMessaging::Config.slack[:username] || 'MessageMe' self.icon_emoji = SlackMessaging::Config.slack[:icon_emoji] || ':mailbox_with_mail' end |
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
3 4 5 |
# File 'lib/slack_messaging/notify_slack.rb', line 3 def channel @channel end |
#icon_emoji ⇒ Object
Returns the value of attribute icon_emoji.
3 4 5 |
# File 'lib/slack_messaging/notify_slack.rb', line 3 def icon_emoji @icon_emoji end |
#icon_url ⇒ Object
Returns the value of attribute icon_url.
3 4 5 |
# File 'lib/slack_messaging/notify_slack.rb', line 3 def icon_url @icon_url end |
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/slack_messaging/notify_slack.rb', line 3 def text @text end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/slack_messaging/notify_slack.rb', line 3 def username @username end |
#webhook_url ⇒ Object
Returns the value of attribute webhook_url.
3 4 5 |
# File 'lib/slack_messaging/notify_slack.rb', line 3 def webhook_url @webhook_url end |
Instance Method Details
#perform ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/slack_messaging/notify_slack.rb', line 13 def perform = { channel: channel, username: username, icon_emoji: icon_emoji, text: text } HTTParty.post(webhook_url, body: .to_json) end |