Sha256: ace52985b58989e42315ba4c5ddf889da68dd0d3b403f1453355980c866df7df

Contents?: true

Size: 325 Bytes

Versions: 5

Compression:

Stored size: 325 Bytes

Contents

# Methods for reading values from a binary stream
module BinaryExtensions
  def read_value(num_bytes)
    bytes = each_byte.take(num_bytes)
    bytes.reverse! if @is_little_endian

    bytes.inject { |total, val| (total << 8) + val }
  end

  def read_ascii(num_bytes)
    each_byte.take(num_bytes).map(&:chr).join
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
file_data-6.0.0 lib/file_data/core_extensions/binary_extensions.rb
file_data-5.2.3 lib/file_data/core_extensions/binary_extensions.rb
file_data-5.2.2 lib/file_data/core_extensions/binary_extensions.rb
file_data-5.2.1 lib/file_data/core_extensions/binary_extensions.rb
file_data-5.2.0 lib/file_data/core_extensions/binary_extensions.rb