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.
960 961 962 963 964 |
# File 'lib/puppeteer/page.rb', line 960 def initialize(client:, handle:, path:) @client = client @handle = handle @path = path end |
Instance Method Details
#read ⇒ Object
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 |
# File 'lib/puppeteer/page.rb', line 966 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 |