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.48 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.47 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.46 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.45 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.44 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.43 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.42 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.41 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.40 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.39 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.38 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.37 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.36 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.35 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.34 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.33 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.32 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.31 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.30 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.29 lib/sportradar/api/basketball/ncaamb/season.rb