Sha256: e2a956ae67502598f2f4e8683899f8fac18c3082c87edbcd77eb14e798130f7c

Contents?: true

Size: 1015 Bytes

Versions: 1

Compression:

Stored size: 1015 Bytes

Contents

module Sportradar
  module Api
    module Football
      class Ncaafb
        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"]
            update(data, **opts)
          end

          def update(data, **opts)
            @conferences_hash = create_data({}, 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

1 entries across 1 versions & 1 rubygems

Version Path
sportradar-api-0.11.0 lib/sportradar/api/football/ncaafb/division.rb