In Ruby how would you define a method
def make_class(method_name, method_body, s_value)
returning a class with the following implementation
class Anonymous
def method_name(args)
method_body(args)
end
def to_s
return s_value
end
end
If you can link to any resources you found useful on basic Ruby metaprogramming that would be great as well.
You can use smth like that:
In that case you are supposed to pass your method’s body as a block (you can replace
|*args|with any list of arguments you want to have as parameters for you method). If you want to passmethod_bodynot as a block but as a string thenevalis your friend.