Class: NbaStats::Team
- Inherits:
-
Object
- Object
- NbaStats::Team
- Defined in:
- lib/nba_stats/team.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#conference ⇒ Object
Returns the value of attribute conference.
-
#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
- .all ⇒ Object
- .create_from_collection(teams_array) ⇒ Object
- .eastern_names ⇒ Object
- .team_names ⇒ Object
- .western_names ⇒ Object
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 unless @@all.include? self end |
Instance Attribute Details
#conference ⇒ Object
Returns the value of attribute conference.
3 4 5 |
# File 'lib/nba_stats/team.rb', line 3 def conference @conference end |
#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 |
.eastern_names ⇒ Object
39 40 41 42 |
# File 'lib/nba_stats/team.rb', line 39 def self.eastern_names east = @@all.select {|team| team.conference == "East"} east.collect {|team| team.name}.sort 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 |
.western_names ⇒ Object
34 35 36 37 |
# File 'lib/nba_stats/team.rb', line 34 def self.western_names west = @@all.select {|team| team.conference == "West"} west.collect {|team| team.name}.sort 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 |