Class: NflData::MySportsFeeds::SeasonalGamesFeed

Inherits:
Object
  • Object
show all
Defined in:
lib/nfl_data/my_sports_feeds/seasonal_games_feed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: MySportsFeeds::Client.new) ⇒ SeasonalGamesFeed

Returns a new instance of SeasonalGamesFeed.



8
9
10
# File 'lib/nfl_data/my_sports_feeds/seasonal_games_feed.rb', line 8

def initialize(client: MySportsFeeds::Client.new)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



6
7
8
# File 'lib/nfl_data/my_sports_feeds/seasonal_games_feed.rb', line 6

def client
  @client
end

Instance Method Details

#feed(season_start_year:) ⇒ Object



12
13
14
15
# File 'lib/nfl_data/my_sports_feeds/seasonal_games_feed.rb', line 12

def feed(season_start_year:)
  response = client.get(endpoint: "#{season_slug(season_start_year)}/games")
  response["games"].map { |data| data["schedule"] }
end

#season_slug(year) ⇒ Object



17
18
19
# File 'lib/nfl_data/my_sports_feeds/seasonal_games_feed.rb', line 17

def season_slug(year)
  "#{year}-#{year + 1}-regular"
end