Hi!
It’s not the first time that I need a to_ruby method which would
guarantee
the following invariant:
Kernel.eval(foo.to_ruby) == foo
It actually works when using inspect with most basic objects (Integer,
String,
True & FalseClass, etc.), without actually being the specification of
inspect.
I admit that such a feature probably only makes sense for classes that
actually
capture datatypes, whose instances are then true values.
Does anyone know a gem that provides such a feature? To your knowledge,
would to_ruby be a conflicting name with existing gems in the ecosystem
or future plans for ruby itself?
Just in case you ask yourself whether this feature is needed, have a
look
at rubygems itself:
Thanks for any suggestion,
Bernard