Class: AhlScraper::Seasons::TeamsService

Inherits:
Object
  • Object
show all
Defined in:
lib/ahl_scraper/services/seasons/teams_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(division_data) ⇒ TeamsService

Returns a new instance of TeamsService.



6
7
8
# File 'lib/ahl_scraper/services/seasons/teams_service.rb', line 6

def initialize(division_data)
  @division_data = division_data
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
# File 'lib/ahl_scraper/services/seasons/teams_service.rb', line 10

def call
  @division_data.map do |division|
    division_name = division.dig(:headers, :name, :properties, :title)
    Array.new(division[:data]).map do |team|
      Team.new(team, division_name)
    end
  end.flatten
end