Class: Stattleship::AtBats

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/stattleship/at_bats.rb

Constant Summary collapse

AT_BATS =
'baseball/mlb/at_bats'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Endpoint

#data

Class Method Details

.fetch(params:) ⇒ Object


5
6
7
8
# File 'lib/stattleship/at_bats.rb', line 5

def self.fetch(params:)
  super(path: AT_BATS,
        params: params)
end

Instance Method Details

#populateObject


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/stattleship/at_bats.rb', line 10

def populate
  at_bats.each do |model|
    populate_games(model)

    games.each do |game|
      populate_game(game)
    end

    populate_hitters(model)
    populate_hitter_teams(model)

    (baseball_pitches || []).each do |pitch|
      populate_pitchers(pitch)
      populate_hitters(pitch)
      populate_teams(pitch)
      populate_hitter_teams(pitch)
    end

    populate_baseball_pitches(model)

  end
end