Class: MLB::Streaks
- Inherits:
-
Shale::Mapper
- Object
- Shale::Mapper
- MLB::Streaks
- Defined in:
- lib/mlb/streaks.rb
Overview
Provides methods for fetching streak data from the API
Instance Attribute Summary collapse
-
#streak_stats ⇒ Array<StreakCategory>
Returns the streak categories.
Class Method Summary collapse
-
.find(streak_type:, season: nil, limit: 10) ⇒ Array<PlayerStreak>
Retrieves streaks by type.
-
.hitting(season: nil, limit: 10) ⇒ Array<PlayerStreak>
Retrieves hitting streaks.
-
.on_base(season: nil, limit: 10) ⇒ Array<PlayerStreak>
Retrieves on-base streaks.
Instance Attribute Details
#streak_stats ⇒ Array<StreakCategory>
Returns the streak categories
138 |
# File 'lib/mlb/streaks.rb', line 138 attribute :streak_stats, StreakCategory, collection: true |
Class Method Details
.find(streak_type:, season: nil, limit: 10) ⇒ Array<PlayerStreak>
Retrieves streaks by type
177 178 179 180 181 182 |
# File 'lib/mlb/streaks.rb', line 177 def self.find(streak_type:, season: nil, limit: 10) season ||= Utils.current_season params = {streakType: streak_type, season:, limit:} response = CLIENT.get("stats/streaks?#{Utils.build_query(params)}") from_json(response).streak_stats.first&.streaks || [] end |
.hitting(season: nil, limit: 10) ⇒ Array<PlayerStreak>
Retrieves hitting streaks
152 153 154 |
# File 'lib/mlb/streaks.rb', line 152 def self.hitting(season: nil, limit: 10) find(streak_type: "hittingStreak", season:, limit:) end |
.on_base(season: nil, limit: 10) ⇒ Array<PlayerStreak>
Retrieves on-base streaks
164 165 166 |
# File 'lib/mlb/streaks.rb', line 164 def self.on_base(season: nil, limit: 10) find(streak_type: "onBaseStreak", season:, limit:) end |