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.13.14 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.13 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.12 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.11 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.10 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.9 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.8 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.7 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.6 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.5 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.4 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.3 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.2 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.1 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.13.0 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.12.3 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.12.2 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.12.1 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.12.0 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.69 lib/sportradar/api/basketball/ncaamb/season.rb