YAML Demo : YAML « XML « Ruby






YAML Demo


require 'yaml'

class Person
  attr_accessor :name, :age
end

fred = Person.new
fred.name = "Fred Bloggs"
fred.age = 45

laura = Person.new
laura.name = "Laura Smith"
laura.age = 23

test_data = [ fred, laura ]

puts YAML::dump(test_data)

 








Related examples in the same category

1.use YAML::dump to convert your Person object array into YAML data
2.Output a hash with yaml
3.Reading and Writing Configuration Files
4.Convert hash to configuration file
5.YAML for Marshaling