Sha256: 6c63c8c55255dfb7421be88f8e8198808db339aa4e05020f42fd69a74634604c

Contents?: true

Size: 1.59 KB

Versions: 125

Compression:

Stored size: 1.59 KB

Contents

module Sportradar
  module Api
    module Basketball
      class Ncaamb
        class Hierarchy < Data
          attr_accessor :response, :id, :name, :alias
          def all_attributes
            [:name, :alias, :conferences, :divisions, :teams]
          end

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

            @id    = data.dig('league', 'id')
            @name  = data.dig('league', 'name')
            @alias = data.dig('league', 'alias')

            @divisions_hash = create_data({}, data['divisions'], klass: Division, hierarchy: self, api: @api)
          end
          def divisions
            @divisions_hash.values
          end
          def division(code_name)
            divisions_by_name[code_name]
          end
          private def divisions_by_name
            @divisions_by_name ||= divisions.map { |d| [d.alias, d] }.to_h
          end
          def conferences
            divisions.flat_map(&:conferences)
          end
          def teams
            conferences.flat_map(&:teams)
          end

          def api
            @api || Sportradar::Api::Basketball::Ncaamb.new
          end

        end
      end
    end
  end
end

__END__

st = sr.standings;

st = sr.standings;
sr = Sportradar::Api::Basketball::Ncaamb.new;
lh = sr.hierarchy;
div = lh.division('D1');
div.teams.count
div.conferences.count
div.conferences.first;
p12 = div.conference('PAC12');
t = p12.team('ARIZ') # => 'id' => "9b166a3f-e64b-4825-bb6b-92c6f0418263"
t = div.teams.sample
res = t.get_roster;
res = t.get_season_stats;

t = lh.teams.first;
t.venue.id

Version data entries

125 entries across 125 versions & 1 rubygems

Version Path
sportradar-api-0.11.29 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.28 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.27 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.26 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.25 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.24 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.23 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.22 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.21 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.20 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.19 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.18 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.17 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.16 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.15 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.14 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.13 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.12 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.11 lib/sportradar/api/basketball/ncaamb/hierarchy.rb
sportradar-api-0.11.10 lib/sportradar/api/basketball/ncaamb/hierarchy.rb