Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/paiement_cic.rb
Instance Method Summary collapse
Instance Method Details
#^(other) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/paiement_cic.rb', line 6 def ^(other) raise ArgumentError, "Can't bitwise-XOR a String with a non-String" \ unless other.kind_of? String raise ArgumentError, "Can't bitwise-XOR strings of different length" \ unless self.length == other.length result = (0..self.length-1).collect { |i| self[i].ord ^ other[i].ord } result.pack("C*") end |