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
.open_with_uri(input, &block) ⇒ Object Also known as: open
112 113 114 115 116 117 118 |
# File 'lib/image_size/uri_reader.rb', line 112 def open_with_uri(input, &block) if input.is_a?(URI) URIReader.open(input, &block) else open_without_uri(input, &block) end end |
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 |