Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/micro_aeth-ae51.rb

Instance Method Summary collapse

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

#byteObject

Returns the first charater in the string as an integer.

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