class LivescorefeedParser::Soccer

Public Class Methods

get_matches(date = nil) click to toggle source
# File lib/livescorefeed_parser/soccer.rb, line 4
def self.get_matches(date = nil)
  options = {
    :games => "livescores",
    :key => LivescorefeedParser.key,
    :format => "json"
  }
  options[:date] = date.to_s if date
  games = {}
  http_response = HTTParty.get('http://livescorefeed.net/data/data.php', query: options)
  if http_response.parsed_response["maininfo"] 
    http_response.parsed_response["maininfo"].each do |id, champ|
      group_name = "#{champ['champname']} - #{champ['country']}"
      games[group_name] = []
      champ["games"].each do |game|
        game_name = "#{game['host']} x #{game['guest']}"
        games[group_name] << [game_name, game["id"]]
      end
    end
  end
  games
end
get_scores(date = nil) click to toggle source
# File lib/livescorefeed_parser/soccer.rb, line 26
def self.get_scores(date = nil)
  options = {
    :games => "livescores",
    :key => LivescorefeedParser.key,
    :format => "json"
  }
  options[:date] = date.to_s if date
  games = {}
  http_response = HTTParty.get('http://livescorefeed.net/data/data.php', query: options)
  if http_response.parsed_response["maininfo"] 
    http_response.parsed_response["maininfo"].each do |id, champ|
      champ["games"].each do |game|
        games[game["id"]] = game
      end
    end
  end
  games
end