Class: MLB::Award

Inherits:
Shale::Mapper
  • Object
show all
Includes:
Comparable, ComparableByAttribute
Defined in:
lib/mlb/award.rb

Overview

Represents an MLB award with recipient and voting information

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ComparableByAttribute

#<=>

Instance Attribute Details

#dateDate

Returns the date the award was given

Examples:

award.date #=> #<Date: 2024-01-23>

Returns:

  • (Date)

    the date the award was given



59
# File 'lib/mlb/award.rb', line 59

attribute :date, Shale::Type::Date

#idString

Returns the unique identifier for the award

Examples:

award.id #=> "MLBHOF"

Returns:

  • (String)

    the unique identifier for the award



27
# File 'lib/mlb/award.rb', line 27

attribute :id, Shale::Type::String

#leagueLeague

Returns the league associated with the award

Examples:

award.league #=> #<MLB::League>

Returns:

  • (League)

    the league associated with the award



91
# File 'lib/mlb/award.rb', line 91

attribute :league, League

#nameString

Returns the name of the award

Examples:

award.name #=> "Hall of Fame"

Returns:

  • (String)

    the name of the award



35
# File 'lib/mlb/award.rb', line 35

attribute :name, Shale::Type::String

#notesString

Returns additional notes about the award

Examples:

award.notes #=> "First ballot"

Returns:

  • (String)

    additional notes about the award



43
# File 'lib/mlb/award.rb', line 43

attribute :notes, Shale::Type::String

#playerPlayer

Returns the player who received the award

Examples:

award.player #=> #<MLB::Player>

Returns:

  • (Player)

    the player who received the award



83
# File 'lib/mlb/award.rb', line 83

attribute :player, Player

#seasonInteger

Returns the season year for the award

Examples:

award.season #=> 2024

Returns:

  • (Integer)

    the season year for the award



67
# File 'lib/mlb/award.rb', line 67

attribute :season, Shale::Type::Integer

#sort_orderInteger

Returns the sort order for display

Examples:

award.sort_order #=> 1

Returns:

  • (Integer)

    the sort order for display



99
# File 'lib/mlb/award.rb', line 99

attribute :sort_order, Shale::Type::Integer

#sportSport

Returns the sport associated with the award

Examples:

award.sport #=> #<MLB::Sport>

Returns:

  • (Sport)

    the sport associated with the award



75
# File 'lib/mlb/award.rb', line 75

attribute :sport, Sport

#votesInteger

Returns the number of votes received

Examples:

award.votes #=> 393

Returns:

  • (Integer)

    the number of votes received



51
# File 'lib/mlb/award.rb', line 51

attribute :votes, Shale::Type::Integer

Instance Method Details

#comparable_attributeSymbol

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the attribute used for sorting

Returns:

  • (Symbol)

    the attribute used for comparison



19
# File 'lib/mlb/award.rb', line 19

def comparable_attribute = :sort_order

#recipients(season: nil) ⇒ Array<Award>

Retrieves recipients of this award for a given season

Examples:

award.recipients(season: 2024) #=> [#<MLB::Award>, ...]

Parameters:

  • season (Integer, nil) (defaults to: nil)

    the season year (defaults to current year)

Returns:

  • (Array<Award>)

    the list of awards with recipients



120
121
122
123
124
# File 'lib/mlb/award.rb', line 120

def recipients(season: nil)
  season ||= Utils.current_season
  response = CLIENT.get("awards/#{id}/recipients?#{Utils.build_query(season:)}")
  Awards.from_json(response).awards
end