Class: NBA::TeamYear

Inherits:
Shale::Mapper
  • Object
show all
Defined in:
lib/nba/team_year.rb

Overview

Represents a year/season a team participated in the league

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#abbreviationString

Returns the team abbreviation for that year

Examples:

team_year.abbreviation #=> "GSW"

Returns:

  • (String)

    the abbreviation



31
# File 'lib/nba/team_year.rb', line 31

attribute :abbreviation, Shale::Type::String

#team_idInteger

Returns the team ID

Examples:

team_year.team_id #=> 1610612744

Returns:

  • (Integer)

    the team ID



15
# File 'lib/nba/team_year.rb', line 15

attribute :team_id, Shale::Type::Integer

#yearInteger

Returns the year

Examples:

team_year.year #=> 2024

Returns:

  • (Integer)

    the year



23
# File 'lib/nba/team_year.rb', line 23

attribute :year, Shale::Type::Integer

Instance Method Details

#seasonString?

Returns the season string

Examples:

team_year.season #=> "2024-25"

Returns:

  • (String, nil)

    the season string



49
50
51
52
53
# File 'lib/nba/team_year.rb', line 49

def season
  return unless year

  Utils.format_season(year)
end

#teamTeam?

Returns the team object

Examples:

team_year.team #=> #<NBA::Team>

Returns:

  • (Team, nil)

    the team object



39
40
41
# File 'lib/nba/team_year.rb', line 39

def team
  Teams.find(team_id)
end