From: martinahansen Date: Mon, 17 Oct 2011 12:56:54 +0000 (+0000) Subject: cleanup of bitarray.rb X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=fe7125d50f560e484bbd108c5ad0830c1cd23029;p=biopieces.git cleanup of bitarray.rb git-svn-id: http://biopieces.googlecode.com/svn/trunk@1580 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_ruby/lib/maasha/bitarray.rb b/code_ruby/lib/maasha/bitarray.rb index d054eb0..13a50f0 100644 --- a/code_ruby/lib/maasha/bitarray.rb +++ b/code_ruby/lib/maasha/bitarray.rb @@ -54,7 +54,7 @@ class BitArray raise BitArrayError, "Position #{pos} must be an integer." unless pos.is_a? Fixnum raise BitArrayError, "Position #{pos} outside of range: 0 ... #{@size}" unless (0 ... @size ).include? pos - (@byte_array[byte_pos(pos)].ord & bit_pos(pos)) != 0 + (@byte_array[byte_pos(pos)] & bit_pos(pos)) != 0 end # Method that returns the number of bits set "on" in a bit array. @@ -62,7 +62,7 @@ class BitArray bits_on = 0 (0 ... self.byte_array.size).each do |byte| - bits_on += @count_array[self.byte_array[byte].ord] + bits_on += @count_array[self.byte_array[byte]] end bits_on @@ -130,11 +130,6 @@ class BitArray raise BitArrayError, "Size must be an integer, not #{@size}" unless @size.is_a? Fixnum raise BitArrayError, "Size must be positive, not #{@size}" unless @size > 0 - byte_array = "" - byte_array << 0.chr * (((@size - 1) / BitsInChar) + 1) - - byte_array - NArray.byte(((@size - 1) / BitsInChar) + 1) end