Class: Rushour::ServerProcess
- Inherits:
-
Object
- Object
- Rushour::ServerProcess
- Defined in:
- lib/rushour/server_process.rb
Constant Summary collapse
- CMD_STOP =
'quit'.freeze
- CMD_PAUSE =
'pause'.freeze
- CMD_UNPAUSE =
'unpause'.freeze
Instance Method Summary collapse
-
#initialize ⇒ ServerProcess
constructor
A new instance of ServerProcess.
- #pause ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #unpause ⇒ Object
Constructor Details
#initialize ⇒ ServerProcess
Returns a new instance of ServerProcess.
9 10 11 12 13 14 |
# File 'lib/rushour/server_process.rb', line 9 def initialize @ottd_server = ChildProcess.build(Rushour::Settings.executable, '-D') @ottd_server.io.stdout = STDOUT @ottd_server.io.stderr = STDERR @ottd_server.duplex = true end |
Instance Method Details
#pause ⇒ Object
25 26 27 |
# File 'lib/rushour/server_process.rb', line 25 def pause @ottd_server.io.stdin.puts CMD_PAUSE end |
#start ⇒ Object
16 17 18 |
# File 'lib/rushour/server_process.rb', line 16 def start @ottd_server.start end |
#stop ⇒ Object
20 21 22 23 |
# File 'lib/rushour/server_process.rb', line 20 def stop @ottd_server.io.stdin.puts CMD_STOP @ottd_server.wait end |
#unpause ⇒ Object
29 30 31 |
# File 'lib/rushour/server_process.rb', line 29 def unpause @ottd_server.io.stdin.puts CMD_UNPAUSE end |