On Mon, 19 Mar 2001, Doug Edmunds wrote:

> I want to concatenate strings which
> then are used as methods.
> In the example, how do I convert
> the string 'a', so I get the
> same result as 'puts b'?
> 
> my_var = "include"
> a = "self." + my_var
> b = self.include
> 
> puts "puts a: #{a}\n"
> puts "puts b: #{b}\n"


I'm not very sure what you mean. I guess you want
to convert a string to a (class) method.

If you want to add a class method, take a look at:
http://www.rubycentral.com/book/ref_c_module.html#module_eval

Here's small example for adding a method (not a class method):

  str = "def test () puts 'a new method added' end"
  self.instance_eval (str)


Hope this answers your question.


Regards,
Paul.