Class: Sportradar::Mlb::SeasonStatistics
- Inherits:
-
TeamsRequest
- Object
- TeamsRequest
- Sportradar::Mlb::SeasonStatistics
- Defined in:
- lib/sportradar/mlb/season_statistics.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(year:, interval_type:) ⇒ SeasonStatistics
constructor
A new instance of SeasonStatistics.
- #perform ⇒ Object
Constructor Details
#initialize(year:, interval_type:) ⇒ SeasonStatistics
Returns a new instance of SeasonStatistics.
4 5 6 7 |
# File 'lib/sportradar/mlb/season_statistics.rb', line 4 def initialize(year:, interval_type:) @year = year || Date.today.strftime('%Y') @interval_type = interval_type || 'reg' end |
Class Method Details
.fetch(year:, interval_type:) ⇒ Object
9 10 11 |
# File 'lib/sportradar/mlb/season_statistics.rb', line 9 def self.fetch(year:, interval_type:) new(year: year, interval_type: interval_type).fetch end |
.perform(year:, interval_type:) ⇒ Object
29 30 31 |
# File 'lib/sportradar/mlb/season_statistics.rb', line 29 def self.perform(year:, interval_type:) new(year: year, interval_type: interval_type).perform end |
Instance Method Details
#fetch ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/sportradar/mlb/season_statistics.rb', line 13 def fetch team_statistics = [] team_ids.each do |team_id| team_statistics << TeamStatistics.new(year: year, interval_type: interval_type, team_id: team_id).fetch end { 'teams' => team_statistics , 'requested_at' => Time.current, 'requested_on' => Time.current.to_date, } end |
#perform ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/sportradar/mlb/season_statistics.rb', line 33 def perform team_ids.each do |team_id| TeamStatistics.new(year: year, interval_type: interval_type, team_id: team_id).save end nil end |