Class: NflData::Api::Player

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parser: Parsers::PlayerParser.new, feed: MySportsFeeds::PlayersFeed.new) ⇒ Player

Returns a new instance of Player.



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

def initialize(parser: Parsers::PlayerParser.new, feed: MySportsFeeds::PlayersFeed.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/player.rb', line 4

def feed
  @feed
end

#parserObject (readonly)

Returns the value of attribute parser.



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

def parser
  @parser
end

Instance Method Details

#players(position: nil) ⇒ Object



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

def players(position: nil)
  player_data = feed.feed(position: position)
  {players: parser.parse(player_data: player_data).map(&:to_h)}.to_json
end