Class: Net::BufferedIO

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

Instance Method Summary collapse

Constructor Details

#initialize(io, debug_output = nil) ⇒ BufferedIO

Returns a new instance of BufferedIO.



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

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

  @io = case io
  when Socket, OpenSSL::SSL::SSLSocket, IO
    io
  when String
    File.exists?(io) ? File.open(io, "r") : StringIO.new(io)
  end
  raise "Unable to create local socket" unless @io
end