Class: ImageSize::URIReader::BodyReader
- Inherits:
-
Object
- Object
- ImageSize::URIReader::BodyReader
- Includes:
- ChunkyReader
- Defined in:
- lib/image_size/uri_reader.rb
Overview
:nodoc:
Instance Method Summary collapse
- #[](offset, length) ⇒ Object
-
#initialize(response) ⇒ BodyReader
constructor
A new instance of BodyReader.
Methods included from ChunkyReader
Methods included from Reader
#fetch, open_with_uri, #stream, #unpack, #unpack1
Constructor Details
#initialize(response) ⇒ BodyReader
Returns a new instance of BodyReader.
28 29 30 31 |
# File 'lib/image_size/uri_reader.rb', line 28 def initialize(response) @body = String.new @body_reader = response.to_enum(:read_body) end |
Instance Method Details
#[](offset, length) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/image_size/uri_reader.rb', line 33 def [](offset, length) if @body_reader begin @body << @body_reader.next while @body.length < offset + length rescue StopIteration, IOError @body_reader = nil end end @body[offset, length] end |