Class: ESPNNBAFantasy::Player

Inherits:
Object
  • Object
show all
Includes:
CalculateStats
Defined in:
lib/espn_nba_fantasy/player.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CalculateStats

#add_calculated_stats

Constructor Details

#initialize(player, team) ⇒ Player

basic initialization with attributes



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

def initialize(player, team)
  @first_name = player['firstName']
  @last_name = player['lastName']
  @full_name = player['fullName']
  @player_id = player['id']
  @position = ESPNNBAFantasy::POSITION_MAP[player['defaultPositionId']-1]
  @stats = stat_card_maker(player)
  @team = team
  @slug = @full_name.scan(/\w+|\s/).join.downcase.split(' ').join('-')
end

Instance Attribute Details

#first_nameObject (readonly)

Returns the value of attribute first_name.



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

def first_name
  @first_name
end

#full_nameObject (readonly)

Returns the value of attribute full_name.



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

def full_name
  @full_name
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



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

def last_name
  @last_name
end

#player_idObject (readonly)

Returns the value of attribute player_id.



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

def player_id
  @player_id
end

#positionObject (readonly)

Returns the value of attribute position.



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

def position
  @position
end

#slugObject (readonly)

Returns the value of attribute slug.



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

def slug
  @slug
end

#statsObject (readonly)

Returns the value of attribute stats.



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

def stats
  @stats
end

#teamObject (readonly)

Returns the value of attribute team.



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

def team
  @team
end

Instance Method Details

#to_sObject



26
27
28
# File 'lib/espn_nba_fantasy/player.rb', line 26

def to_s 
  "Player: #{name} | Position: #{position} | Stats: #{stats}"
end