Class: NbaStats::Player

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_pgObject

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_pgObject

Returns the value of attribute blocks_pg.



2
3
4
# File 'lib/nba_stats/player.rb', line 2

def blocks_pg
  @blocks_pg
end

#experienceObject

Returns the value of attribute experience.



2
3
4
# File 'lib/nba_stats/player.rb', line 2

def experience
  @experience
end

#fg_percentageObject

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_percentageObject

Returns the value of attribute ft_percentage.



2
3
4
# File 'lib/nba_stats/player.rb', line 2

def ft_percentage
  @ft_percentage
end

#heightObject

Returns the value of attribute height.



2
3
4
# File 'lib/nba_stats/player.rb', line 2

def height
  @height
end

#minutes_pgObject

Returns the value of attribute minutes_pg.



2
3
4
# File 'lib/nba_stats/player.rb', line 2

def minutes_pg
  @minutes_pg
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/nba_stats/player.rb', line 2

def name
  @name
end

#numberObject

Returns the value of attribute number.



2
3
4
# File 'lib/nba_stats/player.rb', line 2

def number
  @number
end

#player_urlObject

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_pgObject

Returns the value of attribute points_pg.



2
3
4
# File 'lib/nba_stats/player.rb', line 2

def points_pg
  @points_pg
end

#positionObject

Returns the value of attribute position.



2
3
4
# File 'lib/nba_stats/player.rb', line 2

def position
  @position
end

#rebounds_pgObject

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_pgObject

Returns the value of attribute steals_pg.



2
3
4
# File 'lib/nba_stats/player.rb', line 2

def steals_pg
  @steals_pg
end

#teamObject

Returns the value of attribute team.



2
3
4
# File 'lib/nba_stats/player.rb', line 2

def team
  @team
end

#three_percentageObject

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

.allObject



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_namesObject



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_statsObject



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