Sha256: 059ed13e5ac4d9d1ac544984698190845e33004b658d4bc8f0c3c317701910ca

Contents?: true

Size: 1.02 KB

Versions: 59

Compression:

Stored size: 1.02 KB

Contents

module Sportradar
  module Api
    module Basketball
      class Ncaamb
        class Division < Data
          attr_accessor :response, :id, :name, :alias

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

            @id    = data["id"]
            @name  = data["name"]
            @alias = data["alias"]
            @conferences_hash = {}

            update(data, **opts)
          end

          def update(data, **opts)
             create_data(@conferences_hash, data["conferences"], klass: Conference, division: self, api: @api) if data["conferences"]
          end

          def conferences
            @conferences_hash.values
          end

          def conference(code_name)
            conferences_by_name[code_name]
          end

          def conferences_by_name
            @conferences_by_name ||= conferences.map { |c| [c.alias, c] }.to_h
          end

          def teams
            conferences.flat_map(&:teams)
          end

        end
      end
    end
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
sportradar-api-0.13.14 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.13 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.12 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.11 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.10 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.9 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.8 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.7 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.6 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.5 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.4 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.3 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.2 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.1 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.13.0 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.12.3 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.12.2 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.12.1 lib/sportradar/api/basketball/ncaamb/division.rb
sportradar-api-0.12.0 lib/sportradar/api/basketball/ncaamb/division.rb