Class: Conquer::Mpd::Listener

Inherits:
Object
  • Object
show all
Includes:
Celluloid, Celluloid::Notifications
Defined in:
lib/conquer/mpd.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Listener

Returns a new instance of Listener.



16
17
18
19
20
21
22
# File 'lib/conquer/mpd.rb', line 16

def initialize(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  @host = args.any? ? args.join(':') : nil
  @mpd = INSTANCES[args]
  @events = options[:events]
  async.run
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
# File 'lib/conquer/mpd.rb', line 24

def run
  publish(:mpd, @mpd)
  loop do
    `mpc #{"-h #{@host}" if @host} idle #{@events.join(' ')}`
    publish(:mpd, @mpd)
  end
end