Class: NBAPlayerAPI::Player

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(player_data) ⇒ Player

basic initialization with attributes



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/nba_player_api/player.rb', line 13

def initialize(player_data)
  @player_data_hash = create_player_data_hash(player_data)
  @nba_id = @player_data_hash['PERSON_ID']
  @first_name = @player_data_hash['PLAYER_FIRST_NAME']
  @last_name = @player_data_hash['PLAYER_LAST_NAME']
  @slug = @player_data_hash['PLAYER_SLUG']
  @current_team = @player_data_hash['TEAM_ABBREVIATION']
  @active = @player_data_hash['ROSTER_STATUS']
  @position = @player_data_hash['POSITION']
  @drafted_year = @player_data_hash['DRAFT_YEAR']
  @stat_cards = []
  @stat_cards << create_stat_card
end

Instance Attribute Details

#activeObject (readonly)

Returns the value of attribute active.



7
8
9
# File 'lib/nba_player_api/player.rb', line 7

def active
  @active
end

#current_teamObject (readonly)

Returns the value of attribute current_team.



7
8
9
# File 'lib/nba_player_api/player.rb', line 7

def current_team
  @current_team
end

#drafted_yearObject (readonly)

Returns the value of attribute drafted_year.



7
8
9
# File 'lib/nba_player_api/player.rb', line 7

def drafted_year
  @drafted_year
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



7
8
9
# File 'lib/nba_player_api/player.rb', line 7

def first_name
  @first_name
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



7
8
9
# File 'lib/nba_player_api/player.rb', line 7

def last_name
  @last_name
end

#nba_idObject (readonly)

Returns the value of attribute nba_id.



7
8
9
# File 'lib/nba_player_api/player.rb', line 7

def nba_id
  @nba_id
end

#positionObject (readonly)

Returns the value of attribute position.



7
8
9
# File 'lib/nba_player_api/player.rb', line 7

def position
  @position
end

#slugObject (readonly)

Returns the value of attribute slug.



7
8
9
# File 'lib/nba_player_api/player.rb', line 7

def slug
  @slug
end

#stat_cardsObject (readonly)

Returns the value of attribute stat_cards.



7
8
9
# File 'lib/nba_player_api/player.rb', line 7

def stat_cards
  @stat_cards
end

Instance Method Details

#to_sObject



27
28
29
# File 'lib/nba_player_api/player.rb', line 27

def to_s 
  "Player: #{first_name} #{last_name} | Position: #{position} | Team: #{current_team}"
end