Class: Net::BufferedIO

Inherits:
Object
  • Object
show all
Defined in:
lib/warc/ext/net_http.rb

Instance Method Summary collapse

Constructor Details

#initialize(io, debug_output = nil) ⇒ BufferedIO

Returns a new instance of BufferedIO.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/warc/ext/net_http.rb', line 7

def initialize(io,debug_output = nil)
  @read_timeout = 60
  @rbuf = ''
  @debug_output = debug_output

  @io = case io
  when Socket, OpenSSL::SSL::SSLSocket, StringIO, IO
    io
  when String
    if !io.include?("\0") && File.exists?(io) && !File.directory?(io)
      File.open(io, "r")
    else
      StringIO.new(io)
    end
  end
  raise "Unable to create fake socket from #{io}" unless @io
end