Class: AhlScraper::PlayerGames::DataFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/ahl_scraper/fetchers/player_games/data_fetcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(player_id, season_id) ⇒ DataFetcher

Returns a new instance of DataFetcher.



6
7
8
9
# File 'lib/ahl_scraper/fetchers/player_games/data_fetcher.rb', line 6

def initialize(player_id, season_id)
  @player_id = player_id
  @season_id = season_id
end

Instance Method Details

#callObject



11
12
13
14
15
# File 'lib/ahl_scraper/fetchers/player_games/data_fetcher.rb', line 11

def call
  player_data = JSON.parse(player_data_without_bio, symbolize_names: true)

  player_data&.dig(:gameByGame, 0, :sections, 0, :data)&.map { |data| { **data, position: player_data[:info][:position] } }
end