lib/bitwise.rb in bitwise-0.1.2 vs lib/bitwise.rb in bitwise-0.2.0

- old
+ new

@@ -48,10 +48,17 @@ def get_byte(index) @div, @mod = index.divmod(8) @byte = @value.getbyte(@div) end + def not + result = Bitwise.new + result.value = Bitwise.string_not(self.value) + result + end + alias :~ :not + def intersect(other) min, max = [ self.value, other.value ].sort_by{|i| i.bytesize } result = Bitwise.new result.value = Bitwise.string_intersect(max, min) result @@ -63,9 +70,17 @@ result = Bitwise.new result.value = Bitwise.string_union(max, min) result end alias :| :union + + def xor(other) + min, max = [ self.value, other.value ].sort_by{|i| i.bytesize } + result = Bitwise.new + result.value = Bitwise.string_xor(max, min) + result + end + alias :^ :xor def value=(string) @value = string.force_encoding(Encoding::ASCII_8BIT) @value.bytesize end