Class: MLB::Stats
- Inherits:
-
Shale::Mapper
- Object
- Shale::Mapper
- MLB::Stats
- Defined in:
- lib/mlb/stats.rb
Overview
Provides methods for fetching player stats from the API
Class Method Summary collapse
-
.find(season: nil, group: "hitting", stats: "season", sport: Utils::DEFAULT_SPORT_ID) ⇒ Array<PlayerStat>
Retrieves player stats.
Class Method Details
.find(season: nil, group: "hitting", stats: "season", sport: Utils::DEFAULT_SPORT_ID) ⇒ Array<PlayerStat>
Retrieves player stats
34 35 36 37 38 39 |
# File 'lib/mlb/stats.rb', line 34 def self.find(season: nil, group: "hitting", stats: "season", sport: Utils::DEFAULT_SPORT_ID) season ||= Utils.current_season params = {season:, group:, stats:, sportIds: Utils.extract_id(sport)} response = CLIENT.get("stats?#{Utils.build_query(params)}") from_json(response).stats.first&.splits || [] end |