Class: MLB::Seasons
- Inherits:
-
Shale::Mapper
- Object
- Shale::Mapper
- MLB::Seasons
- Defined in:
- lib/mlb/seasons.rb
Overview
Collection of seasons from the MLB Stats API
Class Method Summary collapse
-
.all(sport: Utils::DEFAULT_SPORT_ID) ⇒ Array<Season>
Retrieves all seasons.
-
.find(season, sport: Utils::DEFAULT_SPORT_ID) ⇒ Season?
Finds a season by ID.
Class Method Details
.all(sport: Utils::DEFAULT_SPORT_ID) ⇒ Array<Season>
Retrieves all seasons
16 17 18 19 20 |
# File 'lib/mlb/seasons.rb', line 16 def self.all(sport: Utils::DEFAULT_SPORT_ID) params = {sportId: Utils.extract_id(sport)} response = CLIENT.get("seasons?#{Utils.build_query(params)}") from_json(response).seasons.sort end |
.find(season, sport: Utils::DEFAULT_SPORT_ID) ⇒ Season?
Finds a season by ID
30 31 32 33 34 |
# File 'lib/mlb/seasons.rb', line 30 def self.find(season, sport: Utils::DEFAULT_SPORT_ID) params = {sportId: Utils.extract_id(sport)} response = CLIENT.get("seasons/#{Utils.extract_id(season)}?#{Utils.build_query(params)}") from_json(response).seasons.min_by { |s| s.id || 0 } end |