18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/korfzone/scraper/games_page.rb', line 18
def games
Array.new.tap do |games|
rows = document.xpath( '//*[@id="ContentPlaceHolder1_UpdatePanel1"]/table[2]/tr[td[ contains( @class, "gameLeagueHeader" ) or contains( @class, "rptItem" ) or contains( @class, "rptAltItem" )]]' )
rows.inject( nil ) do |division,row|
if division.nil? || row.css( 'td.gameLeagueHeader' ).any?
row.text.strip.gsub( /\s+/, ' ' )
else
division.tap do |division|
attributes = parse_game_row( row )
unless attributes.nil?
attributes.merge!( division: division, category: category.to_s, competition: competition )
yield attributes if block_given?
games << attributes
end end end end end end
|