Module: ImageSize::Reader
- Included in:
- ChunkyReader, StringReader
- Defined in:
- lib/image_size/reader.rb,
lib/image_size/uri_reader.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Stream
Class Method Summary collapse
- .open_with_uri(input, &block) ⇒ Object (also: open)
Instance Method Summary collapse
- #fetch(offset, length) ⇒ Object
- #stream(offset) ⇒ Object
- #unpack(offset, length, format) ⇒ Object
- #unpack1(offset, length, format) ⇒ Object
Class Method Details
Instance Method Details
#fetch(offset, length) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/image_size/reader.rb', line 53 def fetch(offset, length) chunk = self[offset, length] unless chunk && chunk.length == length raise FormatError, "Expected #{length} bytes at offset #{offset}, got #{chunk.inspect}" end chunk end |
#stream(offset) ⇒ Object
77 78 79 |
# File 'lib/image_size/reader.rb', line 77 def stream(offset) Stream.new(self, offset) end |
#unpack(offset, length, format) ⇒ Object
63 64 65 |
# File 'lib/image_size/reader.rb', line 63 def unpack(offset, length, format) fetch(offset, length).unpack(format) end |
#unpack1(offset, length, format) ⇒ Object
68 69 70 |
# File 'lib/image_size/reader.rb', line 68 def unpack1(offset, length, format) fetch(offset, length).unpack1(format) end |