Class: Notifier
- Inherits:
-
Object
- Object
- Notifier
- Defined in:
- lib/notifier.rb
Instance Method Summary collapse
-
#initialize(message) ⇒ Notifier
constructor
A new instance of Notifier.
- #notifier ⇒ Object
- #perform ⇒ Object
Constructor Details
#initialize(message) ⇒ Notifier
Returns a new instance of Notifier.
3 4 5 |
# File 'lib/notifier.rb', line 3 def initialize() @message = end |
Instance Method Details
#notifier ⇒ Object
7 8 9 10 11 |
# File 'lib/notifier.rb', line 7 def notifier @notifier ||= Slack::Notifier.new ENV['SLACK_WEBHOOK_URL'] @notifier.username = "Ping My Site" @notifier end |
#perform ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/notifier.rb', line 13 def perform unless $TESTING notification = notifier.ping(@message) if notification.response.code.to_i == 200 puts "Successfully notified to Slack" else puts "Something went wrong when trying to notify Slack" end else return "Successfully notified to Slack" end end |