Skip to content

Instantly share code, notes, and snippets.

@agenteo
Created December 8, 2008 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agenteo/33692 to your computer and use it in GitHub Desktop.
Save agenteo/33692 to your computer and use it in GitHub Desktop.
YAML count
require 'yaml'
class Company
attr_accessor :name, :street, :town, :state, :postcode, :phone, :website, :fax, :categories
end
y = File.open( "companies.yaml" )
counter = 0
yp = YAML::load_documents( y ) { |doc|
counter += 1
puts "P:#{doc.postcode} N: #{doc.name} S:#{doc.street} T:#{doc.town} W:#{doc.website}"
}
puts "TOTAL #{counter}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment