class SportsDataApi::Nfl::Teams
Attributes
json[R]
Public Class Methods
new(json)
click to toggle source
# File lib/sports_data_api/nfl/teams.rb, line 11 def initialize(json) @json = json end
Public Instance Methods
teams()
click to toggle source
# 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