Sha256: d0894da17f726a6eb6e2139f85e8f408e174cf8a5fe064ec7a06e14f96e719f9
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
format_parser-0.3.3 | lib/io_constraint.rb |
format_parser-0.3.2 | lib/io_constraint.rb |
format_parser-0.3.1 | lib/io_constraint.rb |
format_parser-0.3.0 | lib/io_constraint.rb |