class EacRubyUtils::BitArray

def <<(value)

def <<(value)
  push(value)
end

def assert(obj)

def assert(obj)
  return obj if obj.is_a?(self)
  return new(obj) if obj.is_a?(::Enumerable)
  raise "Could not convert #{obj} to #{self}"
end

def byte_bits_enumerator

def byte_bits_enumerator
  ::Enumerator.new do |y|
    offset = 0
    while offset < values_array.count
      y.yield(values_array.slice(offset, ::EacRubyUtils::Byte::BIT_COUNT))
      offset += ::EacRubyUtils::Byte::BIT_COUNT
    end
  end
end

def initialize(values = [])

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

def push(value)

Returns:
  • (EacRubyUtils::Bit) -

Parameters:
  • value (EacRubyUtils::Bit) --
def push(value)
  values_array.push(::EacRubyUtils::Bit.assert(value))
end

def push_array(other_bit_array)

Returns:
  • (EacRubyUtils::BitArray) - +self+.
def push_array(other_bit_array)
  values_array.push(*other_bit_array.to_a)
  self
end

def reverse

Returns:
  • (EacRubyUtils::BitArray) -
def reverse
  self.class.new(values_array.reverse)
end

def to_byte_array(big_endian = false) # rubocop:disable Style/OptionalBooleanParameter

Returns:
  • (EacRubyUtils::ByteArray) -

Parameters:
  • big_endian (Boolean) --
def to_byte_array(big_endian = false) # rubocop:disable Style/OptionalBooleanParameter
  unless count.modulo(::EacRubyUtils::Byte::BIT_COUNT).zero?
    raise 'Bits returned is not multile of 8'
  end
  byte_bits_enumerator.each_with_object(::EacRubyUtils::ByteArray.new) do |e, a|
    a << ::EacRubyUtils::Byte.from_bit_array(e, big_endian)
  end
end

def to_int_array

Returns:
  • (Array) -
def to_int_array
  values_array.map(&:to_i)
end

def values_array

def values_array
  @values_array ||= []
end