Sha256: 358edfb4f31b37af1c8502d215f24fc33f5ba278c5fd9dd701a0627b0da4e5b4

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 Bytes

Contents

require "bindata/single"

module BinData
  # Rest will consume the input stream from the current position to the end of
  # the stream.  This will mainly be useful for debugging and developing.
  #
  #   require 'bindata'
  #
  #   class A < BinData::MultiValue
  #     string :a, :read_length => 5
  #     rest   :rest
  #   end
  #
  #   obj = A.read("abcdefghij")
  #   obj.a #=> "abcde"
  #   obj.rest #=" "fghij"
  #
  class Rest < Single

    # Register this class
    register(self.name, self)

    #---------------
    private

    # Return the string representation that +val+ will take when written.
    def val_to_str(val)
      val
    end

    # Read a number of bytes from +io+ and return the value they represent.
    def read_val(io)
      io.raw_io.read
    end

    # Returns an empty string as default.
    def sensible_default
      ""
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bindata-0.9.1 lib/bindata/rest.rb