J
johng
Hi all
I am new to Ruby so please excuse my question. I did search
usenet for an answer but couldn't find one:
I have a variable, data, that was read from a file and has the
following contents:
def foo
return "foo"
end
My code is this:
amodule = Module.new
amodule.class_eval(data)
puts(amodule.public_instance_methods) -> outputs "foo"
amodule.foo -> fails saying method is
undefined
If I change data to have a class in it with a class method, I can
call it just fine like so:
amodule::Test.foo
Any help very much appreciated.
John.
I am new to Ruby so please excuse my question. I did search
usenet for an answer but couldn't find one:
I have a variable, data, that was read from a file and has the
following contents:
def foo
return "foo"
end
My code is this:
amodule = Module.new
amodule.class_eval(data)
puts(amodule.public_instance_methods) -> outputs "foo"
amodule.foo -> fails saying method is
undefined
If I change data to have a class in it with a class method, I can
call it just fine like so:
amodule::Test.foo
Any help very much appreciated.
John.