Class: FormatParser::EXIFParser::IOExt

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/parsers/exif_parser.rb

Overview

EXIFR kindly requests the presence of a few more methods than what our IOConstraint is willing to provide, but they can be derived from the available ones

Instance Method Summary collapse

Instance Method Details

#readbyteObject Also known as: getbyte



20
21
22
23
24
# File 'lib/parsers/exif_parser.rb', line 20

def readbyte
  if byte = read(1)
    byte.unpack('C').first
  end
end

#seek(n, seek_mode = IO::SEEK_SET) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/parsers/exif_parser.rb', line 26

def seek(n, seek_mode = IO::SEEK_SET)
  io = __getobj__
  case seek_mode
  when IO::SEEK_SET
    io.seek(n)
  when IO::SEEK_CUR
    io.seek(io.pos + n)
  when IO::SEEK_END
    io.seek(io.size + n)
  else
    raise Errno::EINVAL
  end
end