Class: Capybara::Poltergeist::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/poltergeist/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fixed_port = nil, timeout = nil) ⇒ Server

Returns a new instance of Server.



5
6
7
8
9
# File 'lib/capybara/poltergeist/server.rb', line 5

def initialize(fixed_port = nil, timeout = nil)
  @fixed_port = fixed_port
  @timeout    = timeout
  start
end

Instance Attribute Details

#fixed_portObject (readonly)

Returns the value of attribute fixed_port.



3
4
5
# File 'lib/capybara/poltergeist/server.rb', line 3

def fixed_port
  @fixed_port
end

#socketObject (readonly)

Returns the value of attribute socket.



3
4
5
# File 'lib/capybara/poltergeist/server.rb', line 3

def socket
  @socket
end

#timeoutObject

Returns the value of attribute timeout.



3
4
5
# File 'lib/capybara/poltergeist/server.rb', line 3

def timeout
  @timeout
end

Instance Method Details

#portObject



11
12
13
# File 'lib/capybara/poltergeist/server.rb', line 11

def port
  @socket.port
end

#restartObject



27
28
29
30
# File 'lib/capybara/poltergeist/server.rb', line 27

def restart
  stop
  start
end

#send(message) ⇒ Object



32
33
34
# File 'lib/capybara/poltergeist/server.rb', line 32

def send(message)
  @socket.send(message) or raise DeadClient.new(message)
end

#startObject



19
20
21
# File 'lib/capybara/poltergeist/server.rb', line 19

def start
  @socket = WebSocketServer.new(fixed_port, timeout)
end

#stopObject



23
24
25
# File 'lib/capybara/poltergeist/server.rb', line 23

def stop
  @socket.close
end