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

Instance Method Summary collapse

Class Method Details

.open_with_uri(input, &block) ⇒ Object Also known as: open



111
112
113
114
115
116
117
# File 'lib/image_size/uri_reader.rb', line 111

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



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