Class: SportsDataApi::Nfl::Teams
- Inherits:
-
Object
- Object
- SportsDataApi::Nfl::Teams
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/sports_data_api/nfl/teams.rb
Instance Method Summary collapse
-
#initialize(json) ⇒ Teams
constructor
A new instance of Teams.
- #teams ⇒ Object
Constructor Details
#initialize(json) ⇒ Teams
Returns a new instance of Teams.
11 12 13 |
# File 'lib/sports_data_api/nfl/teams.rb', line 11 def initialize(json) @json = json end |
Instance Method Details
#teams ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sports_data_api/nfl/teams.rb', line 15 def teams @teams ||= json.fetch('conferences', []).flat_map do |conference_json| conference = conference_json['name'] conference_json['divisions'].flat_map do |division_json| division = division_json['name'] division_json['teams'].flat_map do |team_json| Team.new(team_json, conference: conference, division: division) end end end end |