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.68 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.67 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.66 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.65 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.64 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.63 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.62 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.61 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.60 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.59 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.58 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.57 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.56 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.55 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.54 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.53 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.52 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.51 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.50 lib/sportradar/api/basketball/ncaamb/season.rb
sportradar-api-0.11.49 lib/sportradar/api/basketball/ncaamb/season.rb