Class: VLC::Server
- Inherits:
-
Object
- Object
- VLC::Server
- Defined in:
- lib/vlc-client/server.rb
Overview
Manages a local VLC server in a child process
Instance Attribute Summary collapse
-
#headless ⇒ Object
(also: #headless?)
Returns the value of attribute headless.
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
-
#daemonize ⇒ Integer
Start a VLC instance as a system deamon.
-
#daemonized? ⇒ Boolean
Queries if VLC is running in daemonized mode.
-
#initialize(host = 'localhost', port = 9595, headless = false) ⇒ Server
constructor
Creates a VLC server lifecycle manager.
-
#running? ⇒ Boolean
(also: #started?)
Queries if VLC is running.
-
#start(detached = false) ⇒ Integer
Starts a VLC instance in a subprocess.
-
#stop ⇒ Integer
Starts a VLC instance in a subprocess.
-
#stopped? ⇒ Boolean
Queries if VLC is stopped.
Constructor Details
#initialize(host = 'localhost', port = 9595, headless = false) ⇒ Server
Creates a VLC server lifecycle manager
15 16 17 18 19 |
# File 'lib/vlc-client/server.rb', line 15 def initialize(host = 'localhost', port = 9595, headless = false) @host, @port, @headless = host, port, headless @pid = NullObject.new @deamon = false end |
Instance Attribute Details
#headless ⇒ Object Also known as: headless?
Returns the value of attribute headless.
4 5 6 |
# File 'lib/vlc-client/server.rb', line 4 def headless @headless end |
#host ⇒ Object
Returns the value of attribute host.
4 5 6 |
# File 'lib/vlc-client/server.rb', line 4 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
4 5 6 |
# File 'lib/vlc-client/server.rb', line 4 def port @port end |
Instance Method Details
#daemonize ⇒ Integer
Start a VLC instance as a system deamon
62 63 64 |
# File 'lib/vlc-client/server.rb', line 62 def daemonize start(true) end |
#daemonized? ⇒ Boolean
Queries if VLC is running in daemonized mode
70 71 72 |
# File 'lib/vlc-client/server.rb', line 70 def daemonized? @deamon == true end |
#running? ⇒ Boolean Also known as: started?
Queries if VLC is running
25 26 27 |
# File 'lib/vlc-client/server.rb', line 25 def running? not @pid.nil? end |
#start(detached = false) ⇒ Integer
Starts a VLC instance in a subprocess
48 49 50 51 52 53 54 |
# File 'lib/vlc-client/server.rb', line 48 def start(detached = false) return @pid if running? detached ? @deamon = true : setup_traps @pid = RUBY_VERSION >= '1.9' ? process_spawn(detached) : process_spawn_ruby_1_8(detached) end |
#stop ⇒ Integer
Starts a VLC instance in a subprocess
79 80 81 82 83 84 85 86 87 |
# File 'lib/vlc-client/server.rb', line 79 def stop return nil if stopped? Process.kill('SIGTERM', pid = @pid) @pid = NullObject.new @deamon = false pid end |
#stopped? ⇒ Boolean
Queries if VLC is stopped
35 36 37 |
# File 'lib/vlc-client/server.rb', line 35 def stopped? not running? end |