class FormatParserPDF::Parser::IOExtension
Public Class Methods
new(io)
click to toggle source
# File lib/format_parser_pdf/io_extension.rb, line 4 def initialize(io) @io = io end
Public Instance Methods
getbyte()
click to toggle source
# File lib/format_parser_pdf/io_extension.rb, line 36 def getbyte if byte = @io.read(1) byte.unpack('C').first end end
readchar()
click to toggle source
# File lib/format_parser_pdf/io_extension.rb, line 32 def readchar @io.read(1) end
rewind()
click to toggle source
# File lib/format_parser_pdf/io_extension.rb, line 28 def rewind @io.seek(0) end
seek(n, seek_mode = IO::SEEK_SET)
click to toggle source
# File lib/format_parser_pdf/io_extension.rb, line 8 def seek(n, seek_mode = IO::SEEK_SET) absolute_offset = case seek_mode when IO::SEEK_SET n when IO::SEEK_CUR @io.pos + n when IO::SEEK_END @io.size + n else raise Errno::EINVAL end if absolute_offset < 0 # Raise a special exception that FormatParser ignores - it will stop the parser and skip to the next one msg = "Can only seek to positive absolute offsets (requested seek to #{absolute_offset})" raise FormatParser::IOUtils::InvalidRead, msg end @io.seek(absolute_offset) end