Class: OpenURI::Buffer
- Inherits:
-
Object
- Object
- OpenURI::Buffer
- Defined in:
- lib/open-uri.rb
Overview
:nodoc: all
Constant Summary collapse
- StringMax =
10240
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #<<(str) ⇒ Object
-
#initialize ⇒ Buffer
constructor
A new instance of Buffer.
- #io ⇒ Object
Constructor Details
#initialize ⇒ Buffer
Returns a new instance of Buffer.
419 420 421 422 |
# File 'lib/open-uri.rb', line 419 def initialize @io = StringIO.new @size = 0 end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
423 424 425 |
# File 'lib/open-uri.rb', line 423 def size @size end |
Instance Method Details
#<<(str) ⇒ Object
426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'lib/open-uri.rb', line 426 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 |