Created
October 18, 2016 02:56
-
-
Save jmmarco/3f200d0da167f05f64174755cd256cb5 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 'csv' | |
module CarLoader | |
def self.get_cars_from_csv(filename) | |
# The result is being passed to the new dealership. | |
# I need to return some useful data from this method... | |
hashed_data = CSV.read(filename, {:headers => true, :header_converters => :symbol}) | |
mapped_data = hashed_data.map {|row| row.to_hash} | |
cars = mapped_data.map! do |car| | |
Car.new(car) | |
end | |
cars | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment