Module: ImageSize::Reader
- Included in:
- ChunkyReader, StringReader
- Defined in:
- lib/image_size/reader.rb,
lib/image_size/uri_reader.rb
Overview
:nodoc:
Class Method Summary collapse
- .open_with_uri(input, &block) ⇒ Object (also: open)
Instance Method Summary collapse
- #fetch(offset, length) ⇒ Object
- #unpack(offset, length, format) ⇒ Object
- #unpack1(offset, length, format) ⇒ Object
Class Method Details
.open_with_uri(input, &block) ⇒ Object Also known as: open
73 74 75 76 77 78 79 |
# File 'lib/image_size/uri_reader.rb', line 73 def open_with_uri(input, &block) if input.is_a?(URI) yield URIReader.new(input) else open_without_uri(input, &block) end end |
Instance Method Details
#fetch(offset, length) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/image_size/reader.rb', line 40 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 |
#unpack(offset, length, format) ⇒ Object
50 51 52 |
# File 'lib/image_size/reader.rb', line 50 def unpack(offset, length, format) fetch(offset, length).unpack(format) end |
#unpack1(offset, length, format) ⇒ Object
55 56 57 |
# File 'lib/image_size/reader.rb', line 55 def unpack1(offset, length, format) fetch(offset, length).unpack1(format) end |