Class: Puppeteer::Page::ProtocolStreamReader
- Inherits:
-
Object
- Object
- Puppeteer::Page::ProtocolStreamReader
- Defined in:
- lib/puppeteer/page.rb
Instance Method Summary collapse
-
#initialize(client:, handle:, path:) ⇒ ProtocolStreamReader
constructor
A new instance of ProtocolStreamReader.
- #read ⇒ Object
Constructor Details
#initialize(client:, handle:, path:) ⇒ ProtocolStreamReader
Returns a new instance of ProtocolStreamReader.
922 923 924 925 926 |
# File 'lib/puppeteer/page.rb', line 922 def initialize(client:, handle:, path:) @client = client @handle = handle @path = path end |
Instance Method Details
#read ⇒ Object
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 |
# File 'lib/puppeteer/page.rb', line 928 def read out = StringIO.new File.open(@path, 'w') do |file| eof = false until eof response = @client.('IO.read', handle: @handle) eof = response['eof'] data = if response['base64Encoded'] Base64.decode64(response['data']) else response['data'] end out.write(data) file.write(data) end end @client.('IO.close', handle: @handle) out.read end |