module FootballCli::Mapper

Public Instance Methods

get_league_id(code) click to toggle source
# File lib/football_cli/mapper.rb, line 5
def get_league_id(code)
  league_info(code).dig(:id)
end
get_qualification(code) click to toggle source
# File lib/football_cli/mapper.rb, line 13
def get_qualification(code)
  league_info(code).dig(:qualification)
end
get_team_id(code) click to toggle source
# File lib/football_cli/mapper.rb, line 9
def get_team_id(code)
  team_info(code).dig(:id)
end

Private Instance Methods

league_info(code) click to toggle source
# File lib/football_cli/mapper.rb, line 19
def league_info(code)
  @league_info ||= parse_json(leagues_path).find {|league| code == league[:league]} || {}
end
leagues_path() click to toggle source
# File lib/football_cli/mapper.rb, line 31
def leagues_path
  File.join root, 'config', 'leagues.json'
end
parse_json(path) click to toggle source
# File lib/football_cli/mapper.rb, line 27
def parse_json(path)
  @parse_json ||= JSON.parse(File.read(path), symbolize_names: true)
end
root() click to toggle source
# File lib/football_cli/mapper.rb, line 39
def root
  File.expand_path '../../../', __FILE__
end
team_info(code) click to toggle source
# File lib/football_cli/mapper.rb, line 23
def team_info(code)
  @team_info ||= parse_json(teams_path).find {|team| code == team[:code]} || {}
end
teams_path() click to toggle source
# File lib/football_cli/mapper.rb, line 35
def teams_path
  File.join root, 'config', 'teams.json'
end