Class: WebChecker::Notifications

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/web_checker/notifications.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#twilioObject (readonly)

Returns the value of attribute twilio.



10
11
12
# File 'lib/web_checker/notifications.rb', line 10

def twilio
  @twilio
end

Instance Method Details

#notifyObject



17
18
19
20
21
22
23
# File 'lib/web_checker/notifications.rb', line 17

def notify
  message = "Your url #{@options['url']} is active now"
  results = []
  results.push(notify_via_email(message))
  results.push(notify_via_twilio(message)) if @twilio
  results.include?(false) ? false : true
end

#notify_broken(count) ⇒ Object



25
26
27
28
29
30
# File 'lib/web_checker/notifications.rb', line 25

def notify_broken(count)
  results = []
  results.push(notify_via_email(build_broken_message(count)))
  results.push(notify_via_twilio(build_broken_message(count))) if @twilio
  results.include?(false) ? false : true
end

#setup(options) ⇒ Object



12
13
14
15
# File 'lib/web_checker/notifications.rb', line 12

def setup(options)
  @options = options
  @twilio = @options['twilio'] ? Twilio::REST::Client.new(@options['twilio_sid'], @options['twilio_token']) : nil
end