Created
September 30, 2008 14:48
-
-
Save Sixeight/13835 to your computer and use it in GitHub Desktop.
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
# よくわからない習作 | |
me = Object.new | |
class << me | |
def get_bind | |
binding | |
end | |
def method_missing(name, *arg) | |
if name.to_s =~ /\Asay_(.*)/ | |
@msg ||= '' | |
@msg += "say \'#{$1.gsub(/_/, ' ')}\'\n" | |
return self | |
end | |
raise NoMethodError, name.to_s | |
end | |
def msg | |
@msg, msg = nil, @msg | |
end | |
end | |
def say(msg) | |
puts msg | |
end | |
begin | |
instance_eval "#{me.say_hello_to_sunshine.say_hohoho.msg}" | |
rescue NoMethodError => e | |
p e.message | |
end | |
eval %q[ def hoge; p'hoge'; self end ], me.get_bind | |
me.hoge.say_hoge.msg.display |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment