Sha256: 9a41cedad7197e3155d27607363b72d872d3252ee1687ffa1cbb0fb3aec6ad33

Contents?: true

Size: 554 Bytes

Versions: 8

Compression:

Stored size: 554 Bytes

Contents

module MLB
  class Player
    attr_accessor :name, :number, :position

    def initialize(attributes={})
      attributes.each_pair do |key, value|
        self.send("#{key}=", value) if self.respond_to?("#{key}=")
      end
    end

    protected

    # 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

8 entries across 8 versions & 1 rubygems

Version Path
mlb-0.3.0 lib/mlb/player.rb
mlb-0.2.6 lib/mlb/player.rb
mlb-0.2.5 lib/mlb/player.rb
mlb-0.2.4 lib/mlb/player.rb
mlb-0.2.3 lib/mlb/player.rb
mlb-0.2.2 lib/mlb/player.rb
mlb-0.2.1 lib/mlb/player.rb
mlb-0.2.0 lib/mlb/player.rb