Class: NbaStats::Team
- Inherits:
-
Object
- Object
- NbaStats::Team
- Defined in:
- lib/nba_stats/team.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#players ⇒ Object
Returns the value of attribute players.
-
#team_url ⇒ Object
Returns the value of attribute team_url.
Class Method Summary collapse
Instance Method Summary collapse
- #add_players ⇒ Object
-
#initialize(team_hash) ⇒ Team
constructor
A new instance of Team.
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
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/nba_stats/team.rb', line 3 def name @name end |
#players ⇒ Object
Returns the value of attribute players.
3 4 5 |
# File 'lib/nba_stats/team.rb', line 3 def players @players end |
#team_url ⇒ Object
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
.all ⇒ Object
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_names ⇒ Object
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_players ⇒ Object
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 |