Class: OpenURI::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/open-uri.rb

Overview

:nodoc:

Constant Summary collapse

StringMax =
10240

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuffer

Returns a new instance of Buffer.



367
368
369
370
# File 'lib/open-uri.rb', line 367

def initialize
  @io = StringIO.new
  @size = 0
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size



371
372
373
# File 'lib/open-uri.rb', line 371

def size
  @size
end

Instance Method Details

#<<(str) ⇒ Object



374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/open-uri.rb', line 374

def <<(str)
  @io << str
  @size += str.length
  if StringIO === @io && StringMax < @size
    require 'tempfile'
    io = Tempfile.new('open-uri')
    io.binmode
    Meta.init io, @io if Meta === @io
    io << @io.string
    @io = io
  end
end

#ioObject



387
388
389
390
# File 'lib/open-uri.rb', line 387

def io
  Meta.init @io unless Meta === @io
  @io
end