Class: ScoreScraper::Scraper

Inherits:
Object
  • Object
show all
Defined in:
lib/score_scraper/scraper.rb

Instance Method Summary collapse

Constructor Details

#initialize(search_date = nil, teams = []) ⇒ Scraper

Returns a new instance of Scraper.



3
4
5
6
# File 'lib/score_scraper/scraper.rb', line 3

def initialize(search_date = nil, teams = [])
  @teams = teams
  @search_date = search_date || Time.now.strftime("%Y-%m-%d")
end

Instance Method Details

#team_gamesObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/score_scraper/scraper.rb', line 8

def team_games
  team_games = []
  (games || []).each do |game|
    if teams.empty? || is_team_game?(game)
      team_games << ScoreScraper::Game.new({
        home_team: home_team(game),
        away_team: away_team(game),
        game_state: game_state(game)
      })
    end
  end

  team_games
end