class FplGsheet::Databank

Public Class Methods

new() click to toggle source
# File lib/fpl_gsheet/databank.rb, line 11
def initialize
  #some stuff outside the scope of this review
  #just assume the fixtures and teams methods work
  @all_data=JSON.load(open("https://fantasy.premierleague.com/api/bootstrap-static/", {ssl_verify_mode: 0}))
  @fixture_data=JSON.load(open("https://fantasy.premierleague.com/api/fixtures/", {ssl_verify_mode: 0}))
end

Public Instance Methods

fixtures() click to toggle source
# File lib/fpl_gsheet/databank.rb, line 18
def fixtures
  #returns array of all Fixtures
  @fixtures ||= @fixture_data.map { |f| Fixture.new(f, self) }
end
fixtures_for_team(id) click to toggle source
# File lib/fpl_gsheet/databank.rb, line 38
def fixtures_for_team(id)
  fixtures.select do |f|
    id==f.data['team_h'] || id==f.data['team_a']
  end
end
gameweeks() click to toggle source
# File lib/fpl_gsheet/databank.rb, line 44
def gameweeks
  @gameweeks ||= @all_data['events']
end
players() click to toggle source
# File lib/fpl_gsheet/databank.rb, line 31
def players
  return @players if defined? @players
  @players = @all_data['elements'].map do |t|
    Player.new(t, self)
  end
end
teams() click to toggle source
# File lib/fpl_gsheet/databank.rb, line 23
def teams
  #returns array of all Teams
  return @teams if defined? @teams
  @teams = @all_data['teams'].map do |t|
    Team.new(t, self)
  end
end