Class: NbaStats::Team

Inherits:
Object
  • Object
show all
Defined in:
lib/nba_stats/team.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(team_hash) ⇒ Team

Returns a new instance of Team.



7
8
9
10
11
12
13
# File 'lib/nba_stats/team.rb', line 7

def initialize(team_hash)
  team_hash.each do |key, value|
    self.send("#{key}=", value)
  end
  @players = []
  @@all << self
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/nba_stats/team.rb', line 3

def name
  @name
end

#playersObject

Returns the value of attribute players.



3
4
5
# File 'lib/nba_stats/team.rb', line 3

def players
  @players
end

#team_urlObject

Returns the value of attribute team_url.



3
4
5
# File 'lib/nba_stats/team.rb', line 3

def team_url
  @team_url
end

Class Method Details

.allObject



26
27
28
# File 'lib/nba_stats/team.rb', line 26

def self.all
  @@all
end

.create_from_collection(teams_array) ⇒ Object



20
21
22
23
24
# File 'lib/nba_stats/team.rb', line 20

def self.create_from_collection(teams_array)
  teams_array.each do |team|
    new_team = NbaStats::Team.new(team)
  end
end

.team_namesObject



30
31
32
# File 'lib/nba_stats/team.rb', line 30

def self.team_names
  @@all.collect {|team| team.name }
end

Instance Method Details

#add_playersObject



15
16
17
18
# File 'lib/nba_stats/team.rb', line 15

def add_players
  players_array = NbaStats::Scraper.get_roster(self)
  NbaStats::Player.create_from_collection_with_team(players_array, self)
end