Skip to content

Instantly share code, notes, and snippets.

@cmaxw
Created August 22, 2013 22:59
Show Gist options
  • Save cmaxw/6313817 to your computer and use it in GitHub Desktop.
Save cmaxw/6313817 to your computer and use it in GitHub Desktop.
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