Sha256: dabc3a98fc58fa8e611b669a0c5b1dd358df588a66b80305d3f8da5ecaab3626
Contents?: true
Size: 572 Bytes
Versions: 1
Compression:
Stored size: 572 Bytes
Contents
module MLB class Player private_class_method :new attr_reader :name, :number, :position private 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.map do |player| new( name: player['player'], number: player['number'], position: player['position'] ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mlb-0.6.2 | lib/mlb/player.rb |