class MLB::Player
Attributes
from[R]
name[R]
number[R]
positions[R]
to[R]
Public Class Methods
all_from_roster(players)
click to toggle source
Returns an array of Player
objects given a team roster
# File lib/mlb/player.rb, line 12 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
new(attributes = {})
click to toggle source
# File lib/mlb/player.rb, line 5 def initialize(attributes = {}) attributes.each do |key, value| instance_variable_set("@#{key}", value) if self.respond_to?(key) end end