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



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/bindata/skip.rb', line 121

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



116
117
118
119
# File 'lib/bindata/skip.rb', line 116

def skip_length
  # no skipping when writing
  0
end