Can any one tell me what wrong I am doing here ?

============================================
require 'csv'

str = <<_
name,age,eligible?
arup,27,
deep,14
Debu,26,y
Ram,30
Sagar,14
_

csv = CSV.new(str,:headers => true,:return_headers => true)

CSV.open('test.csv','w') do |csv_file|
  csv.each do |row|
    csv_file << row
  end
  csv_file.rewind
  csv_file.convert  do |field, info|
    case info[:header]
    when 'eligible?'
      "Y"
    else
      field
    end
  end
end

CSV.foreach('test.csv') do |row|
  p row
end

==========================================

In the output, still no "Y" value present.

# >> ["name", "age", "eligible?"]
# >> ["arup", "27", nil]
# >> ["deep", "14", nil]
# >> ["Debu", "26", "y"]
# >> ["Ram", "30", nil]
# >> ["Sagar", "14", nil]

****************************************

Also I found that, `csv_file.convert  do |field, info|..` line of codes 
are not getting executed. Why so ?

-- 
Posted via http://www.ruby-forum.com/.