Sha256: fdc6639b6f267f25ffbfecd679db8b2d379c81923a00dd8030f6aa00902cfacc

Contents?: true

Size: 733 Bytes

Versions: 18

Compression:

Stored size: 733 Bytes

Contents

require "bindata/base_primitive"

module BinData
  # Counts the number of bytes remaining in the input stream from the current
  # position to the end of the stream.  This only makes sense for seekable
  # streams.
  #
  #   require 'bindata'
  #
  #   class A < BinData::Record
  #     count_bytes_remaining :bytes_remaining
  #     string :all_data, read_length: :bytes_remaining
  #   end
  #
  #   obj = A.read("abcdefghij")
  #   obj.all_data #=> "abcdefghij"
  #
  class CountBytesRemaining < BinData::BasePrimitive
    #---------------
    private

    def value_to_binary_string(val)
      ""
    end

    def read_and_return_value(io)
      io.num_bytes_remaining
    end

    def sensible_default
      0
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
bindata-2.4.15 lib/bindata/count_bytes_remaining.rb
bindata-2.4.14 lib/bindata/count_bytes_remaining.rb
bindata-2.4.13 lib/bindata/count_bytes_remaining.rb
bindata-2.4.12 lib/bindata/count_bytes_remaining.rb
bindata-2.4.11 lib/bindata/count_bytes_remaining.rb
bindata-2.4.10 lib/bindata/count_bytes_remaining.rb
bindata-2.4.9 lib/bindata/count_bytes_remaining.rb
bindata-2.4.8 lib/bindata/count_bytes_remaining.rb
bindata-2.4.7 lib/bindata/count_bytes_remaining.rb
bindata-2.4.6 lib/bindata/count_bytes_remaining.rb
bindata-2.4.5 lib/bindata/count_bytes_remaining.rb
bindata-2.4.4 lib/bindata/count_bytes_remaining.rb
bindata-2.4.3 lib/bindata/count_bytes_remaining.rb
bindata-2.4.2 lib/bindata/count_bytes_remaining.rb
bindata-2.4.1 lib/bindata/count_bytes_remaining.rb
bindata-2.4.0 lib/bindata/count_bytes_remaining.rb
bindata-2.3.5 lib/bindata/count_bytes_remaining.rb
bindata-2.3.4 lib/bindata/count_bytes_remaining.rb