Sha256: e582aec26ded105be5de230cf0064fe454b8c7dcd1b131d09dcfd0d245760b4d

Contents?: true

Size: 1.51 KB

Versions: 180

Compression:

Stored size: 1.51 KB

Contents

module Sportradar
  module Api
    module Basketball
      class Ncaamb
        class Round < Data
          attr_accessor :response, :id, :name, :location, :start, :end, :sequence

          def initialize(data, **opts)
            @response   = data
            @api        = opts[:api]
            @tournament = opts[:tournament]

            @id         = data['id']

            @games_hash = {}

            update(data, **opts)
          end

          def update(data, **opts)
            @response = data

            @name     = data['name']            if data['name']
            @sequence = data['sequence']        if data['sequence']

            update_games(data['games'])         if data['games']
            update_brackets(data['bracketed'])  if data['bracketed']
          end

          def games
            @games_hash.values
          end


          def update_games(data)
            create_data(@games_hash, data, klass: Game, api: @api, season: self)
          end

          def update_brackets(data)
            data.each do |hash|
              create_data(@games_hash, hash['games'], klass: Game, api: @api, round: self, tournament: @tournament)
              # @tournament.update_bracket(data['bracket'].merge('games' => data['games']))
            end
            # hash = {
            #   "bracket"=>{"id"=>"fc853dd0-4744-4735-9e16-5953a155dc1c", "name"=>"East Regional", "location"=>"Philadelphia, PA, USA"},
            #   'games' => [],
            # }

          end

        end
      end
    end
  end
end

Version data entries

180 entries across 180 versions & 1 rubygems

Version Path
sportradar-api-0.10.43 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.42 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.41 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.40 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.39 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.38 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.37 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.36 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.35 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.34 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.33 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.32 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.31 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.30 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.29 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.28 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.27 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.26 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.25 lib/sportradar/api/basketball/ncaamb/round.rb
sportradar-api-0.10.24 lib/sportradar/api/basketball/ncaamb/round.rb