Created
January 4, 2010 22:56
-
-
Save EmmanuelOga/268946 to your computer and use it in GitHub Desktop.
A piece of crap.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is crap. :o | |
# Why did I code this? I should have know better. | |
# only in ruby 1.9 | |
class Stringificator < BasicObject | |
Signature = " > a hidden method < " | |
define_method(Signature) { ::Kernel.binding } | |
def method_missing(x) | |
x.to_s | |
end | |
end | |
def hashify(str) | |
Kernel.eval("{ #{ str } }", Stringificator.new.__send__(Stringificator::Signature)) | |
end | |
puts hashify('a:b, c:d') | |
puts hashify('a:b, c:d').class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment