class Snoop::Notifier

Generic notifier. Create subclasses for different protocols

Constants

DEFAULT_NOTIFY_OPTIONS
UnimplementedException

Attributes

content[RW]

Public Instance Methods

content_changed?() click to toggle source
# File lib/snoop/notifier.rb, line 28
def content_changed?
  old_content = @content
  @content = fetch_content
  old_content != @content
end
fetch_content() click to toggle source
# File lib/snoop/notifier.rb, line 34
def fetch_content
  raise UnimplementedException.new '#fetch_content must be implemented'
end
notify(options = {}) { |content| ... } click to toggle source
# File lib/snoop/notifier.rb, line 15
def notify(options = {})
  options = DEFAULT_NOTIFY_OPTIONS.merge options

  while (
    (options[:count] -= 1) >= 0 ||
    options.fetch(:while).call  ||
    !options.fetch(:until).call
  )
    yield content if content_changed?
    sleep options.fetch(:delay)
  end
end