Class: ImageSize::URIReader::RangeReader
- Inherits:
-
Object
- Object
- ImageSize::URIReader::RangeReader
- Includes:
- HTTPChunkyReader
- Defined in:
- lib/image_size/uri_reader.rb
Overview
:nodoc:
Instance Method Summary collapse
- #chunk(i) ⇒ Object
-
#initialize(http, request_uri, chunk0) ⇒ RangeReader
constructor
A new instance of RangeReader.
Methods included from HTTPChunkyReader
Methods included from ChunkyReader
Methods included from Reader
#fetch, open_with_uri, #stream, #unpack, #unpack1
Constructor Details
#initialize(http, request_uri, chunk0) ⇒ RangeReader
Returns a new instance of RangeReader.
49 50 51 52 53 |
# File 'lib/image_size/uri_reader.rb', line 49 def initialize(http, request_uri, chunk0) @http = http @request_uri = request_uri @chunks = { 0 => chunk0 } end |
Instance Method Details
#chunk(i) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/image_size/uri_reader.rb', line 55 def chunk(i) unless @chunks.key?(i) response = @http.get(@request_uri, chunk_range_header(i)) case response when Net::HTTPPartialContent @chunks[i] = response.body else raise "Unexpected response: #{response}" end end @chunks[i] end |