From: Brian Candler Date: 2011-02-10T17:37:40+09:00 Subject: Re: Ruby coding help Tridib Bandopadhyay wrote in post #980711: > Hello All > > I want to code a method within a ruby source code. Is there any syntax > to call that method(Which I coded) while writing a program in ruby. Certainly. What exactly are you trying to do? You can run arbitrary code from a string using eval(), or from a file using load(). This code can define methods. Once a method is defined, then you can just call it in the usual way. If you want to call a method with a name which is not known until runtime, use send(). >> str = "module M; def self.foo; puts 'whee!'; end; end" => "module M; def self.foo; puts 'whee!'; end; end" >> eval str => nil >> M.foo whee! => nil >> a = "M" => "M" >> b = "foo" => "foo" >> Object.const_get(a).send(b) whee! => nil -- Posted via http://www.ruby-forum.com/.