Class: NflData::Api::Statline

Inherits:
Object
  • Object
show all
Defined in:
lib/nfl_data/api/statline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parser: Parsers::StatlineParser.new, feed: MySportsFeeds::WeeklyPlayerGamelogs.new) ⇒ Statline

Returns a new instance of Statline.



6
7
8
9
# File 'lib/nfl_data/api/statline.rb', line 6

def initialize(parser: Parsers::StatlineParser.new, feed: MySportsFeeds::WeeklyPlayerGamelogs.new)
  @parser = parser
  @feed = feed
end

Instance Attribute Details

#feedObject (readonly)

Returns the value of attribute feed.



4
5
6
# File 'lib/nfl_data/api/statline.rb', line 4

def feed
  @feed
end

#parserObject (readonly)

Returns the value of attribute parser.



4
5
6
# File 'lib/nfl_data/api/statline.rb', line 4

def parser
  @parser
end

Instance Method Details

#statlines(year:, week:) ⇒ Object



11
12
13
14
# File 'lib/nfl_data/api/statline.rb', line 11

def statlines(year:, week:)
  statline_data = feed.feed(season_start_year: year, week: week)
  {statlines: parser.parse(statline_data: statline_data).map(&:to_h)}.to_json
end