Module: Sanfrecce

Defined in:
lib/sanfrecce.rb,
lib/sanfrecce/version.rb

Overview

sanfrecce

Constant Summary collapse

VERSION =
"0.2"

Class Method Summary collapse

Class Method Details

.all_gamesObject



35
36
37
# File 'lib/sanfrecce.rb', line 35

def all_games
  first_stage.merge(second_stage)
end

.first_rankingObject



47
48
49
50
51
52
53
# File 'lib/sanfrecce.rb', line 47

def first_ranking
  rank = {}
  fetch_ranking.css('div:nth-child(3) > table > tr').each do |item|
    rank[html2text(item, 'td:nth-child(1)')] = rank_detail(item)
  end
  rank.delete_if { |key, _value| key == '' }
end

.first_stageObject



19
20
21
22
23
24
25
# File 'lib/sanfrecce.rb', line 19

def first_stage
  games = {}
  fetch_games.css('div:nth-child(4) > table > tr').each do |item|
    games['1st-' + html2text(item, 'td:nth-child(1)')] = game_detail(item)
  end
  games.delete_if { |key, _value| key == '1st-' }
end

.playersObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/sanfrecce.rb', line 8

def players
  html = fetch_players
  players = {}
  html.css('a').each do |item|
    no = item.css('span.uniform_number').text
    name = html2text(item, 'span.player_name > strong')
    players[no] = name
  end
  players
end

.rankingObject



39
40
41
42
43
44
45
# File 'lib/sanfrecce.rb', line 39

def ranking
  rank = {}
  fetch_ranking.css('div:nth-child(5) > table > tr').each do |item|
    rank[html2text(item, 'td:nth-child(1)')] = rank_detail(item)
  end
  rank.delete_if { |key, _value| key == '' }
end

.second_rankingObject



55
56
57
58
59
60
61
# File 'lib/sanfrecce.rb', line 55

def second_ranking
  rank = {}
  fetch_ranking.css('div:nth-child(4) > table > tr').each do |item|
    rank[html2text(item, 'td:nth-child(1)')] = rank_detail(item)
  end
  rank.delete_if { |key, _value| key == '' }
end

.second_stageObject



27
28
29
30
31
32
33
# File 'lib/sanfrecce.rb', line 27

def second_stage
  games = {}
  fetch_games.css('div:nth-child(3) > table > tr').each do |item|
    games['2nd-' + html2text(item, 'td:nth-child(1)')] = game_detail(item)
  end
  games.delete_if { |key, _value| key == '2nd-' }
end