Class: JCukeForker::StatusServer
- Inherits:
-
Object
- Object
- JCukeForker::StatusServer
- Includes:
- Observable
- Defined in:
- lib/jcukeforker/status_server.rb
Instance Attribute Summary collapse
-
#io_in ⇒ Object
readonly
Returns the value of attribute io_in.
Instance Method Summary collapse
- #handle_message(raw_message) ⇒ Object
-
#initialize(io_in) ⇒ StatusServer
constructor
A new instance of StatusServer.
- #run ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(io_in) ⇒ StatusServer
Returns a new instance of StatusServer.
8 9 10 11 |
# File 'lib/jcukeforker/status_server.rb', line 8 def initialize(io_in) @io_in = File.open(io_in, 'r') @io_in.sync = true end |
Instance Attribute Details
#io_in ⇒ Object (readonly)
Returns the value of attribute io_in.
6 7 8 |
# File 'lib/jcukeforker/status_server.rb', line 6 def io_in @io_in end |
Instance Method Details
#handle_message(raw_message) ⇒ Object
30 31 32 33 |
# File 'lib/jcukeforker/status_server.rb', line 30 def () json_obj = JSON.parse fire json_obj.first, *json_obj[1..-1] end |
#run ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/jcukeforker/status_server.rb', line 13 def run @master_thread = Thread.new do loop do = @io_in.gets(sep=$-0) next if .nil? () end end end |
#shutdown ⇒ Object
23 24 25 26 27 28 |
# File 'lib/jcukeforker/status_server.rb', line 23 def shutdown if @io_in @io_in.close @master_thread.terminate end end |