# just using the keys
puts "Col1: #{collection.first["Col1"]}\tCol3: #{collection.first["Col3"]}"
# using 'each' to output each and every hash value
collection.each {|row| # each row is a hash
row.each {|key, value|
if key == 'col1' or key == 'Col3'
puts "#{key}: #{value}"
end
}
puts "-----"
}
|