Class: EspnPub::Entities::Player

Inherits:
Base
  • Object
show all
Defined in:
lib/espn_pub/entities/player.rb

Overview

Represents a player on a team.

Instance Attribute Summary collapse

Attributes inherited from Base

#client

Instance Method Summary collapse

Constructor Details

#initialize(id:, sport:, league:, first_name: nil, last_name: nil, position: nil, team_id: nil) ⇒ Player

Initialize a Player entity.

Parameters:

  • id (String)

    The player identifier.

  • sport (String)

    The sport name.

  • league (String)

    The league identifier.

  • first_name (String, nil) (defaults to: nil)

    The player’s first name.

  • last_name (String, nil) (defaults to: nil)

    The player’s last name.

  • position (String, nil) (defaults to: nil)

    The player’s position abbreviation.

  • team_id (String, nil) (defaults to: nil)

    The identifier of the player’s team.



24
25
26
27
28
29
30
31
32
33
# File 'lib/espn_pub/entities/player.rb', line 24

def initialize(id:, sport:, league:, first_name: nil, last_name: nil, position: nil, team_id: nil)
  @id = id
  @sport = sport
  @league = league
  @first_name = first_name
  @last_name = last_name
  @position = position
  @team_id = team_id
  super()
end

Instance Attribute Details

#first_nameObject (readonly)

Returns the value of attribute first_name.



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

def first_name
  @first_name
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



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

def last_name
  @last_name
end

#leagueObject (readonly)

Returns the value of attribute league.



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

def league
  @league
end

#positionObject (readonly)

Returns the value of attribute position.



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

def position
  @position
end

#sportObject (readonly)

Returns the value of attribute sport.



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

def sport
  @sport
end

#team_idObject (readonly)

Returns the value of attribute team_id.



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

def team_id
  @team_id
end

Instance Method Details

#full_nameString

Return the player’s full name.

Returns:

  • (String)

    The player’s full name.



38
39
40
# File 'lib/espn_pub/entities/player.rb', line 38

def full_name
  @full_name ||= first_name + ' ' + last_name
end