> > A couple of things I haven't figured out:
> >
> > 1. What does ruby use when outputting the object id for object.inspect?
> > Either I can't get the formatting right, or it's not the object id.
(Compare
> > object_to_s with inspect.)
>

I think we need a pure ruby solution here. At least for this hole. :-)

A regular expression would do the trick:

irb(main):003:0> o = Object.new
=> #<Object:0x277c828>
irb(main):005:0> r = /:(0x.*?)[\s>]/
=> /:(0x.*?)[\s>]/
irb(main):007:0> o.inspect =~ r
=> 8
irb(main):008:0> $1
=> "0x277c828"
irb(main):009:0> o.instance_eval('@a=1')
=> 1
irb(main):010:0> o.inspect
=> "#<Object:0x277c828 @a=1>"
irb(main):011:0> o.inspect =~ r
=> 8
irb(main):012:0> $1
=> "0x277c828"

Seems to work pretty well, although I have no idea how we would get that
value for things like arrays and strings.

--
John Long
http://wiseheartdesign.com