Class: Brewer::Slacker
- Inherits:
-
Object
- Object
- Brewer::Slacker
- Defined in:
- lib/brewer/slacker.rb
Overview
This class is responsible for slack communication
Instance Attribute Summary collapse
-
#brewer ⇒ Object
Returns the value of attribute brewer.
-
#slack ⇒ Object
Returns the value of attribute slack.
Instance Method Summary collapse
-
#configure_slack ⇒ Object
This will look for a webhook in settings.yml and ask you for one if it doesn’t find one.
-
#initialize ⇒ Slacker
constructor
A new instance of Slacker.
-
#monitor(delay = 10) ⇒ Object
This does the same thing as Brewer#monitor, but it also sends a slack message after a specified wait, normally 10 minutes.
-
#ping(message = "ping at #{Time.now}") ⇒ Object
This sends a message in slack.
Constructor Details
Instance Attribute Details
#brewer ⇒ Object
Returns the value of attribute brewer.
7 8 9 |
# File 'lib/brewer/slacker.rb', line 7 def brewer @brewer end |
#slack ⇒ Object
Returns the value of attribute slack.
7 8 9 |
# File 'lib/brewer/slacker.rb', line 7 def slack @slack end |
Instance Method Details
#configure_slack ⇒ Object
This will look for a webhook in settings.yml and ask you for one if it doesn’t find one
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/brewer/slacker.rb', line 16 def configure_slack unless @settings.settings['webhook_url'] print "Slack Webhook URL: " webhook_url = gets.chomp @settings.add({ 'webhook_url' => webhook_url }) end return Slack::Notifier.new @settings.settings['webhook_url'] end |
#monitor(delay = 10) ⇒ Object
This does the same thing as Brewer#monitor, but it also sends a slack message after a specified wait, normally 10 minutes
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/brewer/slacker.rb', line 36 def monitor(delay=10) while true do table = @brewer.status_table before_temp = @brewer.pv @brewer.wait(to_seconds(delay)) diff = @brewer.pv - before_temp clear_screen puts table ping([ "Current Temperature: #{@brewer.pid['pv_temp']} F", "Set Value Temperature: #{@brewer.pid['sv_temp']} F", "Current temperature has climed #{diff} F since #{delay} minute(s) ago", "Sent at #{Time.now.strftime("%H:%M")}" ].join("\n")) end true end |
#ping(message = "ping at #{Time.now}") ⇒ Object
This sends a message in slack. If an array is passed in, it will send it as one message with new lines between each array item
30 31 32 |
# File 'lib/brewer/slacker.rb', line 30 def ping(="ping at #{Time.now}") @slack.ping() end |