class RNotify::Client

Public Class Methods

new(server_uri, password) click to toggle source
# File lib/r_notify/client.rb, line 6
def initialize(server_uri, password)
  @server_uri = server_uri
  @server = DRbObject.new_with_uri(@server_uri)
  @password = password
  GirFFI.setup :Notify
  Notify.init("Rubote notify")
end

Public Instance Methods

start() click to toggle source
# File lib/r_notify/client.rb, line 14
def start
  puts "Listening for notifications from #{@server_uri}"
  loop do
    message = @server.listen(@password)
    next if message == :heartbeat
    notification(message).show
  end
end

Private Instance Methods

notification(message) click to toggle source
# File lib/r_notify/client.rb, line 25
def notification message
  buffer = message[:buffer]
  prefix = message[:prefix]
  message = message[:message]
  Notify::Notification.new(
    "<i>#{buffer || "Query"}:</i>",
    "<b>#{prefix}</b> | #{message}",
    "dialog-information"
  )
end