The hex logic will handle hex numbers that aren't prefixed by '0x'.  I'm not sure if that's desirable or not (I lean towards not).  I'm actually a bit surprised that Ruby doesn't have a core mechanism for directly handling hex string / number comparisons.  This is the best I could come up with using built-in methods instead of regexing the string and it will handle prefixed and unprefixed hex numbers.
```
value.to_s.downcase == sprintf('%#x', value.to_s.hex) or
value.to_s.downcase == sprintf('%x', value.to_s.hex)
```

Something else to consider is if '0x' and '0X' are both valid prefixes.