A small program I wrote to learn about meta programming.
1. Still need to refactor the code to read csv files in other directories. 2. Package as Gem
The CSV file:
“FirstName”,LastName,age Paul,“Johnson”,87 “Douglas”,“Hofstadter”,60 To require and make a CsvRecord: require ‘lib/csvrecord’
CsvRecord.make("author.csv")
records = Author.read records.each do |author| puts author.firstname + “ ” + author.lastname end
Output:
Paul Johnson Douglas Hofstadter