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>


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"


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>


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

attribute :league, League

#nameString

Returns the name of the award

Examples:

award.name #=> "Hall of Fame"


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"


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>


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

attribute :player, Player

#seasonInteger

Returns the season year for the award

Examples:

award.season #=> 2024


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


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>


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

attribute :sport, Sport

#votesInteger

Returns the number of votes received

Examples:

award.votes #=> 393


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



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>, ...]


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