Class: NbaStats::Player
- Inherits:
-
Object
- Object
- NbaStats::Player
- Defined in:
- lib/nba_stats/player.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#assists_pg ⇒ Object
Returns the value of attribute assists_pg.
-
#blocks_pg ⇒ Object
Returns the value of attribute blocks_pg.
-
#experience ⇒ Object
Returns the value of attribute experience.
-
#fg_percentage ⇒ Object
Returns the value of attribute fg_percentage.
-
#ft_percentage ⇒ Object
Returns the value of attribute ft_percentage.
-
#height ⇒ Object
Returns the value of attribute height.
-
#minutes_pg ⇒ Object
Returns the value of attribute minutes_pg.
-
#name ⇒ Object
Returns the value of attribute name.
-
#number ⇒ Object
Returns the value of attribute number.
-
#player_url ⇒ Object
Returns the value of attribute player_url.
-
#points_pg ⇒ Object
Returns the value of attribute points_pg.
-
#position ⇒ Object
Returns the value of attribute position.
-
#rebounds_pg ⇒ Object
Returns the value of attribute rebounds_pg.
-
#steals_pg ⇒ Object
Returns the value of attribute steals_pg.
-
#team ⇒ Object
Returns the value of attribute team.
-
#three_percentage ⇒ Object
Returns the value of attribute three_percentage.
Class Method Summary collapse
- .all ⇒ Object
- .create_from_collection(players_array) ⇒ Object
- .create_from_collection_with_team(players_array, team) ⇒ Object
- .player_names ⇒ Object
Instance Method Summary collapse
- #add_player_stats ⇒ Object
-
#initialize(player_hash) ⇒ Player
constructor
A new instance of Player.
Constructor Details
#initialize(player_hash) ⇒ Player
Returns a new instance of Player.
6 7 8 9 10 11 |
# File 'lib/nba_stats/player.rb', line 6 def initialize(player_hash) player_hash.each do |key, value| self.send("#{key}=", value) end @@all << self end |
Instance Attribute Details
#assists_pg ⇒ Object
Returns the value of attribute assists_pg.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def assists_pg @assists_pg end |
#blocks_pg ⇒ Object
Returns the value of attribute blocks_pg.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def blocks_pg @blocks_pg end |
#experience ⇒ Object
Returns the value of attribute experience.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def experience @experience end |
#fg_percentage ⇒ Object
Returns the value of attribute fg_percentage.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def fg_percentage @fg_percentage end |
#ft_percentage ⇒ Object
Returns the value of attribute ft_percentage.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def ft_percentage @ft_percentage end |
#height ⇒ Object
Returns the value of attribute height.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def height @height end |
#minutes_pg ⇒ Object
Returns the value of attribute minutes_pg.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def minutes_pg @minutes_pg end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def name @name end |
#number ⇒ Object
Returns the value of attribute number.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def number @number end |
#player_url ⇒ Object
Returns the value of attribute player_url.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def player_url @player_url end |
#points_pg ⇒ Object
Returns the value of attribute points_pg.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def points_pg @points_pg end |
#position ⇒ Object
Returns the value of attribute position.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def position @position end |
#rebounds_pg ⇒ Object
Returns the value of attribute rebounds_pg.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def rebounds_pg @rebounds_pg end |
#steals_pg ⇒ Object
Returns the value of attribute steals_pg.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def steals_pg @steals_pg end |
#team ⇒ Object
Returns the value of attribute team.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def team @team end |
#three_percentage ⇒ Object
Returns the value of attribute three_percentage.
2 3 4 |
# File 'lib/nba_stats/player.rb', line 2 def three_percentage @three_percentage end |
Class Method Details
.all ⇒ Object
34 35 36 |
# File 'lib/nba_stats/player.rb', line 34 def self.all @@all end |
.create_from_collection(players_array) ⇒ Object
13 14 15 16 17 |
# File 'lib/nba_stats/player.rb', line 13 def self.create_from_collection(players_array) players_array.each do |player| new_player = NbaStats::Player.new(player) end end |
.create_from_collection_with_team(players_array, team) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/nba_stats/player.rb', line 19 def self.create_from_collection_with_team(players_array, team) players_array.each do |player| new_player = NbaStats::Player.new(player) new_player.team = team team.players << new_player end end |
.player_names ⇒ Object
38 39 40 |
# File 'lib/nba_stats/player.rb', line 38 def self.player_names @@all.collect {|player| player.name} end |
Instance Method Details
#add_player_stats ⇒ Object
27 28 29 30 31 32 |
# File 'lib/nba_stats/player.rb', line 27 def add_player_stats stats_hash = NbaStats::Scraper.get_player_stats(self) stats_hash.each do |key,value| self.send("#{key}=", value) end end |