class Npbs::Matches

Public Class Methods

new() click to toggle source
Calls superclass method Npbs::NPB::new
# File lib/npbs.rb, line 135
def initialize
  super
  @path = "/#{Date.today.year}/games/"
end

Public Instance Methods

today() click to toggle source
# File lib/npbs.rb, line 139
def today
  result = []
  fetch_doc.css(".contentsgame").each do |node|
    node.css("tr:nth-child(odd)").each do |game|

      h_team = game.css("td:nth-child(2)").inner_text.gsub(/(\s| )+/, '')
      h_score = game.css("td:nth-child(3)").inner_text.gsub(/(\s| )+/, '')

      v_score = game.css("td:nth-child(5)").inner_text.gsub(/(\s| )+/, '')
      v_team = game.css("td:nth-child(6)").inner_text.gsub(/(\s| )+/,'')

      result << Match.new(TeamResult.new(h_team, h_score),
                          TeamResult.new(v_team, v_score))
    end
  end
  result
end