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)
-
(EacRubyUtils::Bit)
-
Parameters:
-
value
(EacRubyUtils::Bit
) --
def push(value) values_array.push(::EacRubyUtils::Bit.assert(value)) end
def push_array(other_bit_array)
-
(EacRubyUtils::BitArray)
- +self+.
def push_array(other_bit_array) values_array.push(*other_bit_array.to_a) self end
def reverse
-
(EacRubyUtils::BitArray)
-
def reverse self.class.new(values_array.reverse) end
def to_byte_array(big_endian = false) # rubocop:disable Style/OptionalBooleanParameter
-
(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
-
(Array
-)
def to_int_array values_array.map(&:to_i) end
def values_array
def values_array @values_array ||= [] end