Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/micro_aeth-ae51.rb
Instance Method Summary collapse
-
#^(str) ⇒ Object
XOR two strings.
-
#byte ⇒ Object
The first charater in the string as an integer.
Instance Method Details
#^(str) ⇒ Object
XOR two strings
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/micro_aeth-ae51.rb', line 15 def ^ str if str.class == String str = str.byte elsif str.class == Fixnum nil else raise "invalid arg: #{str.class} \n Must be String or Fixnum" end self.bytes.each do |i| str = str ^ i end str.chr.force_encoding( "ASCII-8BIT") end |
#byte ⇒ Object
Returns the first charater in the string as an integer.
8 9 10 |
# File 'lib/micro_aeth-ae51.rb', line 8 def byte self.bytes[0] end |