Sha256: b6318e37229cb9face8a022bf9c9895657afa79d5f0382e6838a57ac03ce5177
Contents?: true
Size: 1015 Bytes
Versions: 17
Compression:
Stored size: 1015 Bytes
Contents
require "bindata/base_primitive" module BinData # Skip will skip over bytes from the input stream. If the stream is not # seekable, then the bytes are consumed and discarded. # # When writing, skip will write <tt>:length</tt> number of zero bytes. # # require 'bindata' # # class A < BinData::Record # skip :length => 5 # string :a, :read_length => 5 # end # # obj = A.read("abcdefghij") # obj.a #=> "fghij" # # == Parameters # # Skip objects accept all the params that BinData::BasePrimitive # does, as well as the following: # # <tt>:length</tt>:: The number of bytes to skip. # class Skip < BinData::BasePrimitive mandatory_parameter :length #--------------- private def value_to_binary_string(val) len = eval_parameter(:length) "\000" * len end def read_and_return_value(io) len = eval_parameter(:length) io.seekbytes(len) "" end def sensible_default "" end end end
Version data entries
17 entries across 17 versions & 2 rubygems