Class: Puppeteer::ProtocolStreamReader

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

Instance Method Summary collapse

Constructor Details

#initialize(client:, handle:, path:) ⇒ ProtocolStreamReader

Returns a new instance of ProtocolStreamReader.



2
3
4
5
6
# File 'lib/puppeteer/protocol_stream_reader.rb', line 2

def initialize(client:, handle:, path:)
  @client = client
  @handle = handle
  @path = path
end

Instance Method Details

#readObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/puppeteer/protocol_stream_reader.rb', line 8

def read
  StringIO.open do |out|
    if @path
      File.open(@path, 'wb') do |file|
        io_read do |data|
          out.write(data)
          file.write(data)
        end
      end
    else
      io_read { |data| out.write(data) }
    end
    io_close

    out.string
  end
end