module BinData::SkipUntilValidPlugin

Logic for the :until_valid parameter

Public Instance Methods

read_and_return_value(io) click to toggle source
# File lib/bindata/skip.rb, line 116
def read_and_return_value(io)
  prototype = get_parameter(:until_valid)
  validator = prototype.instantiate(nil, self)

  valid = false
  until valid
    begin
      io.with_readahead do
        validator.read(io)
        valid = true
      end
    rescue ValidityError
      io.readbytes(1)
    end
  end
end
skip_length() click to toggle source
# File lib/bindata/skip.rb, line 111
def skip_length
  # no skipping when writing
  0
end