Convertir une chaîne hexadécimale en un hexagone int

- Je convertir une chaîne hexadécimale d'un nombre entier hexadécimal, comme ceci:

color = "0xFF00FF" #can be any color else, defined by functions
colorto = 0xFF00FF #copy of color, but from string to integer without changes

Je peux avoir le format RGB.

Je suis obligé de le faire parce que cette fonction va après :

def i2s int, len
  i = 1
  out = "".force_encoding('binary')
  max = 127**(len-1)

  while i <= len
    num = int/max
    int -= num*max
    out << (num + 1)
    max /= 127
    i += 1
  end

  out
end

J'ai vu ici que hexadécimal les nombres entiers existent. Quelqu'un peut-il m'aider avec ce problème?

source d'informationauteur FrereDePute