lib/sportradar/api/basketball/ncaamb/season.rb in sportradar-api-0.10.2 vs lib/sportradar/api/basketball/ncaamb/season.rb in sportradar-api-0.10.3

- old
+ new

@@ -1,33 +1,46 @@ module Sportradar module Api module Basketball class Ncaamb class Season < Basketball::Season - attr_accessor :response, :id, :name, :alias + attr_accessor :response, :id, :name, :alias, :year def initialize(data, **opts) @response = data @api = opts[:api] @id = data.dig('league', 'id') @name = data.dig('league', 'name') @alias = data.dig('league', 'alias') + @year = data.dig('season', 'year') + @type = data.dig('season', 'type') + @games_hash = {} - update_games(data['games']) + @tournaments_hash = {} + update_games(data['games']) if data['games'] + update_tournaments(data['tournaments']) if data['tournaments'] end def games @games_hash.values end - def year - 2016 # what is this doing here? + def tournaments + @tournaments_hash.values end + def tournament(id) + @tournaments_hash[id] + end + def update_games(data) create_data(@games_hash, data, klass: Game, api: @api, season: self) + end + + def update_tournaments(data) + create_data(@tournaments_hash, data, klass: Tournament, api: @api, season: self) end end end end