On Nov 21, 2011, at 8:26 PM, Robert Klemme wrote:

> 2011/11/21 Jes Gabriel y Gal <jgabrielygalan / gmail.com>:
>> On Mon, Nov 21, 2011 at 6:55 PM, hari mahesh <harismahesh / gmail.com> wrote:
>>> Consider I have a ruby file called library.rb.
>>> 
>>> In which i defined a function like this :
>>> 
>>> def Name(testcase, result)
>>> pdf = PDF::Writer.new
>>> testcase= $testcase
>>> pdf.text $testcase, :font_size => 72, :justification => :center
>>> result= $result
>>> pdf.text $result, :font_size => 72, :justification => :center
>>> end
>>> 
>>> now i have another ruby file named web.rb which calls thus library.rb.
>>> 
>>> My Problem is I need to pass these arguments separately.
>>> 
>>> Means , I need to call Testcase argument firstly and then after many
>>> conditions I need to pass result as Pass or fail.
>>> 

If I understand that correctly, what you're looking for is actually textbook partial application or currying/schfinkeling. If you're using Ruby 1.9 you can use Proc#curry directly like so:

# unbind the method and convert it to Proc to use #curry
report = method(:Name).to_proc.curry[testcase]

# and later apply the second argument
report[result]

Alternatively, you can also implement partial application like this:

# define a lambda that that captures your test case in a closure so you can pass the result later
report = lambda { |result| Name(testcase, result) }

# later, execute the lambda with your result
report[result]

Note that in your case it is probably better to follow the advice posted by Jesus and Robert for a cleaner solution. It's just that functional programming is fun, and your question really seemed to call for partial application!

Sylvester