Class: Net::BufferedIO

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

Instance Method Summary collapse

Instance Method Details

#initialize_with_fakeweb(io, debug_output = nil) ⇒ Object Also known as: initialize



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

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

  @io = case io
  when Socket, OpenSSL::SSL::SSLSocket, 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 local socket" unless @io
end