Sha256: 183586e7092dcee077e0c0be25c764badaf4240c7c599a2ff8a01a3241e2cb3c

Contents?: true

Size: 719 Bytes

Versions: 3

Compression:

Stored size: 719 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/byte'
require 'eac_ruby_utils/patches/module/compare_by'

module EacRubyUtils
  class ByteArray
    delegate :to_a, :size, :count, :length, :[], :fetch, to: :values_array
    compare_by :values_array

    def initialize(values = [])
      values.each { |value| push(value) }
    end

    def <<(value)
      push(value)
    end

    # @param value [EacRubyUtils::Byte]
    # @return [EacRubyUtils::Byte]
    def push(value)
      values_array.push(::EacRubyUtils::Byte.assert(value))
    end

    # @return [Array<Integer>]
    def to_int_array
      values_array.map(&:to_i)
    end

    private

    def values_array
      @values_array ||= []
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eac_ruby_utils-0.91.0 lib/eac_ruby_utils/byte_array.rb
eac_ruby_utils-0.90.0 lib/eac_ruby_utils/byte_array.rb
eac_ruby_utils-0.89.0 lib/eac_ruby_utils/byte_array.rb