Created
August 22, 2013 22:59
-
-
Save cmaxw/6313817 to your computer and use it in GitHub Desktop.
This file contains 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 Baseballer | |
class Batter | |
attr_accessor :attributes | |
def self.load(file_path = "../../data/Batting-07-12.csv") | |
path_to_file = File.expand_path(file_path, File.dirname(__FILE__)) | |
batters = [] | |
CSV.foreach(path_to_file, headers: true, return_headers: false) do |row| | |
batter = self.new(row.to_hash) | |
batters << batter | |
end | |
batters | |
end | |
def initialize(row) | |
@attributes = row | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment