Class: Capybara::Poltergeist::Server
- Inherits:
-
Object
- Object
- Capybara::Poltergeist::Server
- Defined in:
- lib/capybara/poltergeist/server.rb
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize(timeout = nil) ⇒ Server
constructor
A new instance of Server.
- #restart ⇒ Object
- #send(message) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(timeout = nil) ⇒ Server
Returns a new instance of Server.
5 6 7 8 9 |
# File 'lib/capybara/poltergeist/server.rb', line 5 def initialize(timeout = nil) @port = Util.find_available_port @timeout = timeout start end |
Instance Attribute Details
#port ⇒ Object (readonly)
Returns the value of attribute port.
3 4 5 |
# File 'lib/capybara/poltergeist/server.rb', line 3 def port @port end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
3 4 5 |
# File 'lib/capybara/poltergeist/server.rb', line 3 def socket @socket end |
#timeout ⇒ Object
Returns the value of attribute timeout.
3 4 5 |
# File 'lib/capybara/poltergeist/server.rb', line 3 def timeout @timeout end |
Instance Method Details
#restart ⇒ Object
23 24 25 26 |
# File 'lib/capybara/poltergeist/server.rb', line 23 def restart stop start end |
#send(message) ⇒ Object
28 29 30 |
# File 'lib/capybara/poltergeist/server.rb', line 28 def send() @socket.send() or raise DeadClient.new() end |
#start ⇒ Object
15 16 17 |
# File 'lib/capybara/poltergeist/server.rb', line 15 def start @socket = WebSocketServer.new(port, timeout) end |
#stop ⇒ Object
19 20 21 |
# File 'lib/capybara/poltergeist/server.rb', line 19 def stop @socket.close end |