Sha256: 225ef0f5db3d6b51a9ba42455ad0b414c11245d96d7dc76513184d61a2622216

Contents?: true

Size: 1.17 KB

Versions: 125

Compression:

Stored size: 1.17 KB

Contents

module Sportradar
  module Api
    module Basketball
      class Nba
        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")
            @season = Season.new(data['season']) if data['season']
            @conferences_hash = create_data({}, data['conferences'], klass: Conference, hierarchy: self, api: @api)
          end
          def conferences
            @conferences_hash.values
          end
          def divisions
            conferences.flat_map(&:divisions)
          end
          def teams
            divisions.flat_map(&:teams)
          end

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

        end
      end
    end
  end
end

__END__

st = sr.standings;
sr = Sportradar::Api::Basketball::Nba.new
lh = sr.league_hierarchy;
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/nba/hierarchy.rb
sportradar-api-0.11.28 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.27 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.26 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.25 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.24 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.23 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.22 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.21 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.20 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.19 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.18 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.17 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.16 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.15 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.14 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.13 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.12 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.11 lib/sportradar/api/basketball/nba/hierarchy.rb
sportradar-api-0.11.10 lib/sportradar/api/basketball/nba/hierarchy.rb