-
-
Save jcasimir/926572 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "fastercsv" | |
class SalAttend | |
attr_accessor :file | |
attr_accessor :headers | |
# Added the parameter here... | |
def initialize(filename) | |
puts "JSAttend Initialized" | |
# and call the open_file method here... | |
open_file(filename) | |
end | |
def open_file(filename) | |
puts "Trying to open the file with FasterCSV" | |
@file = FasterCSV.open(filename, {:headers => true, :return_headers => true, :header_converters => :symbol}) | |
@headers = @file.readline | |
end | |
def print_names | |
@file.each do |line| | |
puts line[:first_name] + " " + line[:last_name] | |
end | |
end | |
end | |
# Then you'll have to specify the filename here... | |
jsa = SalAttend.new("event_attendees.csv") | |
jsa.print_names |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment