Generate Ruby style object ids
The default to_s
method for Ruby objects includes the object id encoded as a hexadecimal: #<Object:0x000001009e60f8>
. When you add a to_s
method to your own objects, you lose that hexadecimal value. Hexoid gives it back.
require 'hexoid' class A def to_s "<%s:%s>" % [self.class.name, hexoid] end end obj = A.new puts obj # => "<A:0x10103a380>" puts obj.hexoid # => "0x10103a380"
Get it in one of the following ways:
-
gem install hexoid
-
git clone git://github.com/delano/hexoid.git
-
gem install delano-hexoid --source http://gems.github.com
-
Does not work in JRuby
-
Delano Mandelbaum (solutious.com)
See LICENSE.txt