Class: MLB::TeamStats
- Inherits:
-
Shale::Mapper
- Object
- Shale::Mapper
- MLB::TeamStats
- Defined in:
- lib/mlb/team_stats.rb
Overview
Provides methods for fetching team stats from the API
Instance Attribute Summary collapse
-
#stats ⇒ Array<TeamStatGroup>
Returns the stat groups.
Class Method Summary collapse
-
.find(season: nil, group: "hitting", stats: "season") ⇒ Array<TeamStat>
Retrieves team stats.
Instance Attribute Details
#stats ⇒ Array<TeamStatGroup>
Returns the stat groups
28 |
# File 'lib/mlb/team_stats.rb', line 28 attribute :stats, TeamStatGroup, collection: true |
Class Method Details
.find(season: nil, group: "hitting", stats: "season") ⇒ Array<TeamStat>
Retrieves team stats
45 46 47 48 49 50 |
# File 'lib/mlb/team_stats.rb', line 45 def self.find(season: nil, group: "hitting", stats: "season") season ||= Utils.current_season params = {season:, group:, stats:} response = CLIENT.get("teams/stats?#{Utils.build_query(params)}") from_json(response).stats.first&.splits || [] end |