Module: Candelabra::Pianobar
- Defined in:
- lib/candelabra/pianobar.rb
Overview
The Pianobar module of Candelabra handles starting and stopping of pianobar. The module will contain the PID of the process. It will also be able to kill of the pianobar’s running on the system
For Example:
Candelabra::Pianobar.start
# => pianobar has started
Defined Under Namespace
Classes: Execute, PID, Start, Stop, StopAll
Class Method Summary collapse
-
.execute ⇒ Object
An implementation of the command pattern see the GOF book…
-
.pid ⇒ Object
The accessor for the PID.
-
.restart ⇒ Object
First stop all running pianobar instances and then start up a new one.
-
.running? ⇒ Boolean
Check to determine if pianobar is running anywhere on the system.
-
.start ⇒ Object
Start the pianobar.
-
.stop ⇒ Object
Die pianobar die!!!! Yeah that is what it does.
-
.stop_all ⇒ Object
When killing one pianobar is not enough.
Class Method Details
.execute ⇒ Object
An implementation of the command pattern see the GOF book…
86 87 88 |
# File 'lib/candelabra/pianobar.rb', line 86 def execute @execute ||= Execute.new end |
.pid ⇒ Object
The accessor for the PID. If this is nil then no process has been started
Returns int or nil
19 20 21 22 |
# File 'lib/candelabra/pianobar.rb', line 19 def pid return @pid unless @pid.nil? @pid = execute.command :pid end |
.restart ⇒ Object
First stop all running pianobar instances and then start up a new one
Example:
Candelabra::Pianobar.restart
# => pianobar is stoped and then restarted
Returns nothing
65 66 67 68 |
# File 'lib/candelabra/pianobar.rb', line 65 def restart stop_all start end |
.running? ⇒ Boolean
Check to determine if pianobar is running anywhere on the system
Returns true or false
27 28 29 |
# File 'lib/candelabra/pianobar.rb', line 27 def running? !pid.nil? end |
.start ⇒ Object
Start the pianobar. ( bet you couldn’t have guessed that one ) It will take the output pianobar and redirect it to logs/out.log in the gem folder.
Example:
Candelabra::Pianobar.start
# => gives you the process ID
Returns the process ID a.k.a pid
40 41 42 |
# File 'lib/candelabra/pianobar.rb', line 40 def start @pid = execute.command :start end |
.stop ⇒ Object
Die pianobar die!!!! Yeah that is what it does. If you have a PID then this will send the kill command to that process
Example:
Candelabra::Pianobar.stop
# => pianobar is done for
Returns nothing
52 53 54 55 |
# File 'lib/candelabra/pianobar.rb', line 52 def stop execute.commands[:stop] = Stop.new(pid) execute.command :stop end |
.stop_all ⇒ Object
When killing one pianobar is not enough. Kill them all. This will send a system command to kill all of the pianobars running on the system. This is useful because of rouge pianobars and stuff
Example:
Candelabra::Pianobar.stop_all
# => and they are all dead
Returns nothing useful
80 81 82 |
# File 'lib/candelabra/pianobar.rb', line 80 def stop_all @pid = execute.command :stop_all end |