Module: BinData::SkipUntilValidPlugin

Defined in:
lib/bindata/skip.rb

Overview

Logic for the :until_valid parameter

Instance Method Summary collapse

Instance Method Details

#read_and_return_value(io) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# 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_lengthObject



111
112
113
114
# File 'lib/bindata/skip.rb', line 111

def skip_length
  # no skipping when writing
  0
end