Class: MLB::HighLow

Inherits:
Shale::Mapper
  • Object
show all
Defined in:
lib/mlb/high_low.rb

Overview

Provides methods for fetching high/low stats from the API

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#high_low_resultsArray<HighLowGroup>

Returns the high/low results

Examples:

high_low.high_low_results #=> [#<MLB::HighLowGroup>, ...]

Returns:



101
# File 'lib/mlb/high_low.rb', line 101

attribute :high_low_results, HighLowGroup, collection: true

Class Method Details

.find(org_type:, season: nil) ⇒ Array<HighLowResult>

Retrieves high/low stats for teams

Examples:

Get high/low stats for teams

MLB::HighLow.find(org_type: "team", season: 2024)

Parameters:

  • org_type (String)

    the organization type (team, league, sport)

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

    the season year (defaults to current year)

Returns:



115
116
117
118
119
# File 'lib/mlb/high_low.rb', line 115

def self.find(org_type:, season: nil)
  season ||= Utils.current_season
  response = CLIENT.get("highLow/#{org_type}?#{Utils.build_query(season:)}")
  from_json(response).high_low_results.flat_map(&:splits)
end