/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
class Kung mstr = %- def foo puts 'Hello World from Kung.foo' puts caller(0).inspect end - module_eval mstr end Kung.new.foo class Monkey line, mstr = __LINE__, %- def see puts 'Hello World from Monkey.see' puts caller(0) end - module_eval mstr, __FILE__, line end Monkey.new.see class Monkey module_eval(<<-EOS, __FILE__, __LINE__) def see puts 'Hello World from Monkey.see' puts caller(0) end EOS end Monkey.new.see