Class: NbaRb::Player::Career

Inherits:
Object
  • Object
show all
Includes:
Initializable, StatsHash, StatsRequest
Defined in:
lib/nba_rb/player/career.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StatsHash

#create_stats_hash

Methods included from StatsRequest

#stats_request

Constructor Details

#initialize(*args) ⇒ Career

Returns a new instance of Career.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nba_rb/player/career.rb', line 21

def initialize(*args)
  super(*args)

  @per_mode ||= NbaRb::PerMode.per_game
  @league_id ||= NbaRb::League.NBA

  res = stats_request('playercareerstats', 'PlayerID' => player_id,
                                           'LeagueID' => league_id,
                                           'PerMode' => per_mode)

  @data = res['resultSets']
end

Class Attribute Details

.endpointObject (readonly)

Returns the value of attribute endpoint.



9
10
11
# File 'lib/nba_rb/player/career.rb', line 9

def endpoint
  @endpoint
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



16
17
18
# File 'lib/nba_rb/player/career.rb', line 16

def data
  @data
end

#league_idObject

Returns the value of attribute league_id.



16
17
18
# File 'lib/nba_rb/player/career.rb', line 16

def league_id
  @league_id
end

#per_modeObject

Returns the value of attribute per_mode.



16
17
18
# File 'lib/nba_rb/player/career.rb', line 16

def per_mode
  @per_mode
end

#player_idObject

Returns the value of attribute player_id.



16
17
18
# File 'lib/nba_rb/player/career.rb', line 16

def player_id
  @player_id
end

Instance Method Details

#all_star_season_totalsObject



62
63
64
# File 'lib/nba_rb/player/career.rb', line 62

def all_star_season_totals
  create_stats_hash(@data[4])
end

#all_star_season_totals_by_year(year) ⇒ Object



66
67
68
69
70
# File 'lib/nba_rb/player/career.rb', line 66

def all_star_season_totals_by_year(year)
  all_star_season_totals.each do |hash|
    return hash if hash['SEASON_ID'].include? year
  end
end

#career_all_star_season_totalsObject



72
73
74
# File 'lib/nba_rb/player/career.rb', line 72

def career_all_star_season_totals
  create_stats_hash(@data[5])
end

#career_college_season_totalsObject



86
87
88
# File 'lib/nba_rb/player/career.rb', line 86

def career_college_season_totals
  create_stats_hash(@data[7])
end

#college_season_totalsObject



76
77
78
# File 'lib/nba_rb/player/career.rb', line 76

def college_season_totals
  create_stats_hash(@data[6])
end

#college_season_totals_by_year(year) ⇒ Object



80
81
82
83
84
# File 'lib/nba_rb/player/career.rb', line 80

def college_season_totals_by_year(year)
  college_season_totals.each do |hash|
    return hash if hash['SEASON_ID'].include? year
  end
end

#endpointObject



12
13
14
# File 'lib/nba_rb/player/career.rb', line 12

def endpoint
  self.class.endpoint
end

#post_season_career_totalsObject



58
59
60
# File 'lib/nba_rb/player/career.rb', line 58

def post_season_career_totals
  create_stats_hash(@data[3])
end

#post_season_rankingsObject



100
101
102
# File 'lib/nba_rb/player/career.rb', line 100

def post_season_rankings
  create_stats_hash(@data[9])
end

#post_season_rankings_by_year(year) ⇒ Object



104
105
106
107
108
# File 'lib/nba_rb/player/career.rb', line 104

def post_season_rankings_by_year(year)
  post_season_rankings.each do |hash|
    return hash if hash['SEASON_ID'].include? year
  end
end

#post_season_totalsObject



48
49
50
# File 'lib/nba_rb/player/career.rb', line 48

def post_season_totals
  create_stats_hash(@data[2])
end

#post_season_totals_by_year(year) ⇒ Object



52
53
54
55
56
# File 'lib/nba_rb/player/career.rb', line 52

def post_season_totals_by_year(year)
  post_season_totals.each do |hash|
    return hash if hash['SEASON_ID'].include? year
  end
end

#regular_season_career_totalsObject



44
45
46
# File 'lib/nba_rb/player/career.rb', line 44

def regular_season_career_totals
  create_stats_hash(@data[1])
end

#regular_season_rankingsObject



90
91
92
# File 'lib/nba_rb/player/career.rb', line 90

def regular_season_rankings
  create_stats_hash(@data[8])
end

#regular_season_rankings_by_year(year) ⇒ Object



94
95
96
97
98
# File 'lib/nba_rb/player/career.rb', line 94

def regular_season_rankings_by_year(year)
  regular_season_rankings.each do |hash|
    return hash if hash['SEASON_ID'].include? year
  end
end

#regular_season_totalsObject



34
35
36
# File 'lib/nba_rb/player/career.rb', line 34

def regular_season_totals
  create_stats_hash(@data[0])
end

#season_totals_by_year(year) ⇒ Object



38
39
40
41
42
# File 'lib/nba_rb/player/career.rb', line 38

def season_totals_by_year(year)
  regular_season_totals.each do |hash|
    return hash if hash['SEASON_ID'].include? year
  end
end