Class: Puppeteer::WebSocket::DriverImpl

Inherits:
Object
  • Object
show all
Defined in:
lib/puppeteer/web_socket.rb

Overview

providing #url, #write(string)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ DriverImpl

Returns a new instance of DriverImpl.



8
9
10
11
12
13
# File 'lib/puppeteer/web_socket.rb', line 8

def initialize(url)
  @url = url

  endpoint = URI.parse(url)
  @socket = TCPSocket.new(endpoint.host, endpoint.port)
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



15
16
17
# File 'lib/puppeteer/web_socket.rb', line 15

def url
  @url
end

Instance Method Details

#readpartial(maxlen = 1024) ⇒ Object



23
24
25
26
27
# File 'lib/puppeteer/web_socket.rb', line 23

def readpartial(maxlen = 1024)
  @socket.readpartial(maxlen)
rescue Errno::ECONNRESET
  raise EOFError.new('closed by remote')
end

#write(data) ⇒ Object



17
18
19
20
21
# File 'lib/puppeteer/web_socket.rb', line 17

def write(data)
  @socket.write(data)
rescue Errno::EPIPE
  raise EOFError.new('already closed')
end