Class: FootballNow::Importer
- Inherits:
-
Object
- Object
- FootballNow::Importer
- Defined in:
- lib/importer.rb
Class Method Summary collapse
- .create_leagues ⇒ Object
- .create_matches ⇒ Object
- .create_teams ⇒ Object
- .generate ⇒ Object
- .matches_hash(league_url) ⇒ Object
- .teams_hash(league_url) ⇒ Object
Class Method Details
.create_leagues ⇒ Object
12 13 14 15 16 |
# File 'lib/importer.rb', line 12 def self.create_leagues FootballNow::Scraper.scrape_leagues.each do |league| FootballNow::League.create_from_hash(league) end end |
.create_matches ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/importer.rb', line 30 def self.create_matches FootballNow::League.all.each do |league| matches_hash(league.league_url).each do |match_hash| FootballNow::Match.create_from_hash(match_hash) end end end |
.create_teams ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/importer.rb', line 18 def self.create_teams FootballNow::League.all.each do |league| teams_hash(league.league_url).each do |team_hash| FootballNow::Team.create_from_hash(team_hash) end end end |
.generate ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/importer.rb', line 3 def self.generate create_leagues puts "#{FootballNow::League.all.count} Leagues loaded..." create_teams puts "#{FootballNow::Team.all.count} Teams loaded..." create_matches puts "#{FootballNow::Match.all.count} Matches loaded..." end |
.matches_hash(league_url) ⇒ Object
38 39 40 |
# File 'lib/importer.rb', line 38 def self.matches_hash(league_url) FootballNow::Scraper.scrape_matches(league_url) end |
.teams_hash(league_url) ⇒ Object
26 27 28 |
# File 'lib/importer.rb', line 26 def self.teams_hash(league_url) FootballNow::Scraper.scrape_teams(league_url) end |