]> git.donarmstrong.com Git - biopieces.git/commitdiff
cleanup of bitarray.rb
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 17 Oct 2011 12:56:54 +0000 (12:56 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 17 Oct 2011 12:56:54 +0000 (12:56 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1580 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/lib/maasha/bitarray.rb

index d054eb07a5db394ae12e1e1634dc391b21c11376..13a50f0ecaa0dde5adb79ae91c5f7e473a63c0de 100644 (file)
@@ -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