On Thu, Oct 6, 2011 at 1:24 AM, ideal one <idealone5 / hotmail.com> wrote:

> =A0 =A0 Thanks for your Info, Sorry if i am not clear with my requirement=
.
> Let me clearly explain below: I am looking for DATA DRIVEN Scenario.
>
> I read CSV file and use that data in my code. ie If i have 10 rows, i
> will run my program 10 times.

> i will have to iterate each time into my code and use different row
> values, its sort of Data Driven Automation.
> let me know if my requirement makes sense.

You can directly assign fields to block parameters and have your code
inside the foreach loop:

13:27:13 Temp$ ./csv.rb data.csv
name=3DJames                          country=3DUSA
name=3DRobert                         country=3DGermany
name=3DMichael                        country=3DNeverland
13:27:18 Temp$ cat data.csv
James,bar,USA
Robert,bbb,Germany
Michael,ignore,Neverland
13:27:27 Temp$ cat -n csv.rb
     1  #!/bin/env ruby19
     2
     3  require 'csv'
     4
     5  CSV.foreach ARGV.shift do |name, ign1, country|
     6    printf "name=3D%-30s country=3D%-30s\n", name, country
     7  end
13:28:18 Temp$

Of course you can invoke any method from there as well.

Kind regards

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/