Skip to content

Instantly share code, notes, and snippets.

@Sixeight
Created September 30, 2008 14:48
Show Gist options
  • Save Sixeight/13835 to your computer and use it in GitHub Desktop.
Save Sixeight/13835 to your computer and use it in GitHub Desktop.
# よくわからない習作
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