Class: FplGsheet::Databank
- Inherits:
-
Object
- Object
- FplGsheet::Databank
- Defined in:
- lib/fpl_gsheet/databank.rb
Instance Method Summary collapse
- #fixtures ⇒ Object
- #fixtures_for_team(id) ⇒ Object
- #gameweeks ⇒ Object
-
#initialize ⇒ Databank
constructor
A new instance of Databank.
- #players ⇒ Object
- #teams ⇒ Object
Constructor Details
#initialize ⇒ Databank
Returns a new instance of Databank.
11 12 13 14 15 16 |
# 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 |
Instance Method Details
#fixtures ⇒ Object
18 19 20 21 |
# 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) ⇒ Object
38 39 40 41 42 |
# 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 ⇒ Object
44 45 46 |
# File 'lib/fpl_gsheet/databank.rb', line 44 def gameweeks @gameweeks ||= @all_data['events'] end |