[code]records = YAML.load_file("myfile.yml")
records.each do |record|
puts record.inspect
end[/code]
I want to be able to read an arbitrary yml file, then print out each of
the element one by one.
In the above example, my output is
#<RmEnv label_label_id: 8, data_id: 27, data_val: "MJP-PR2">
#<RmEnv label_label_id: 8, data_id: 28, data_val: "MJP-QA2">
I know I can do
puts record.label_label_id
puts record.data_id
puts record.data_val
but that only works when reading myfile.yml. If reading other yml, it'll
be a different object.
I was hoping something like this would work
[code]
record.each do |key|
puts record[key]
end[/code]
But RoR throw an error, undefined method 'each' for #<RmEnv ... >
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---