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



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

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



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

def skip_length
  # no skipping when writing
  0
end