Sha256: 990e496c40b3acc9d2ca699d313176fd7c475fc30fe01b1ea02248a9a0d234a5
Contents?: true
Size: 678 Bytes
Versions: 1
Compression:
Stored size: 678 Bytes
Contents
module MLB class Player attr_reader :name, :number, :positions, :from, :to def initialize(attributes = {}) attributes.each do |key, value| instance_variable_set("@#{key}", value) if self.respond_to?(key) end end # Returns an array of Player objects given a team roster def self.all_from_roster(players) players.select { |player| player['to'].nil? }.map do |player| new( :name => player['player'], :number => player['number'].to_i, :positions => player['position'], :from => player['from'].to_i, :to => 'Present' ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mlb-0.7.0 | lib/mlb/player.rb |