Sha256: 310681bf713a6ba3d1be639976792fb0c90c80bda17d7680e5a4fe9a2a39973f

Contents?: true

Size: 1.36 KB

Versions: 181

Compression:

Stored size: 1.36 KB

Contents

module Sportradar
  module Api
    module Basketball
      class Ncaamb
        class Season < Basketball::Season
          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 = {}
            @tournaments_hash = {}
            update_games(data['games'])             if data['games']
            update_tournaments(data['tournaments']) if data['tournaments']
          end

          def games
            @games_hash.values
          end

          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
  end
end

__END__

sr = Sportradar::Api::Basketball::Ncaamb.new
sd = sr.daily_schedule;
ss = sr.schedule;

Version data entries

181 entries across 181 versions & 1 rubygems

Version Path
sportradar-api-0.11.8 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.7 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.6 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.5 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.4 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.3 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.1 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.0 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.10.55 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.10.54 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.10.53 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.10.52 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.10.51 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.10.50 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.10.49 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.10.48 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.10.47 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.10.46 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.10.45 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.10.44 lib/sportradar/api/basketball/ncaamb/season.rb