Sha256: 9ee41772b50b6d26740b36f1185b4426e5918610e9494483cb1e117b8f43d4b6
Contents?: true
Size: 1.12 KB
Versions: 5
Compression:
Stored size: 1.12 KB
Contents
# We deliberately want to document and restrict the # number of methods an IO-ish object has to implement # to be usable with all our parsers. This subset is fairly # thin and well defined, and all the various IO limiters # and cache facilities in the library are guaranteed to # support those methods. This wrapper is used to guarantee # that the parser can only call those specific methods and # nothing more. Consequently, if the parser uses a gem that # for some reason needs additional IO methods to be available # this parser has to provide it's own extensions to that end. # # The rationale for including a method in this subset is as follows: # we include a method if other methods can be implemented on top of it. # For example, should some parser desire `IO#readbyte`, it can be # implemented in terms of a `read()`. Idem for things like `IO#eof?`, # `IO#rewind` and friends. class FormatParser::IOConstraint def initialize(io) @io = io end def read(n_bytes) @io.read(n_bytes) end def seek(absolute_offset) @io.seek(absolute_offset) end def size @io.size end def pos @io.pos end end
Version data entries
5 entries across 5 versions & 1 rubygems