class CampfireChat::Monitor
Attributes
last_run_time[RW]
Public Class Methods
retry_time()
click to toggle source
# File lib/campfire_chat/monitor.rb, line 6 def self.retry_time 30 end
run()
click to toggle source
# File lib/campfire_chat/monitor.rb, line 14 def self.run instance.run end
sleep_time()
click to toggle source
# File lib/campfire_chat/monitor.rb, line 10 def self.sleep_time retry_time / 2 end
Public Instance Methods
check_client?()
click to toggle source
# File lib/campfire_chat/monitor.rb, line 39 def check_client? return true if last_run_time.nil? last_run_time + self.class.retry_time < Time.now end
check_messages()
click to toggle source
# File lib/campfire_chat/monitor.rb, line 28 def check_messages client.messages.each do |message| notification = prepare_notification(message) notifier.push(notification) end end
client()
click to toggle source
# File lib/campfire_chat/monitor.rb, line 48 def client @client ||= CampfireChat::Client.new end
notifier()
click to toggle source
# File lib/campfire_chat/monitor.rb, line 52 def notifier @notifier ||= CampfireChat::Notifier::Growl.instance end
prepare_notification(message)
click to toggle source
# File lib/campfire_chat/monitor.rb, line 44 def prepare_notification(message) CampfireChat::Notification.build(message) end
run()
click to toggle source
# File lib/campfire_chat/monitor.rb, line 18 def run loop do if check_client? check_messages set_last_run_time sleep self.class.sleep_time end end end
set_last_run_time()
click to toggle source
# File lib/campfire_chat/monitor.rb, line 35 def set_last_run_time self.last_run_time = Time.now end