Class: Sportradar::Api::Basketball::Ncaamb::Hierarchy

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/basketball/ncaamb/hierarchy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Data

#attributes, #create_data, #parse_into_array, #parse_into_array_with_options, #parse_out_hashes, #structure_links, #update_data

Constructor Details

#initialize(data, **opts) ⇒ Hierarchy

Returns a new instance of Hierarchy.



11
12
13
14
15
16
17
18
19
20
# File 'lib/sportradar/api/basketball/ncaamb/hierarchy.rb', line 11

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

Instance Attribute Details

#aliasObject

Returns the value of attribute alias.



6
7
8
# File 'lib/sportradar/api/basketball/ncaamb/hierarchy.rb', line 6

def alias
  @alias
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/sportradar/api/basketball/ncaamb/hierarchy.rb', line 6

def id
  @id
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/sportradar/api/basketball/ncaamb/hierarchy.rb', line 6

def name
  @name
end

#responseObject

Returns the value of attribute response.



6
7
8
# File 'lib/sportradar/api/basketball/ncaamb/hierarchy.rb', line 6

def response
  @response
end

Instance Method Details

#all_attributesObject



7
8
9
# File 'lib/sportradar/api/basketball/ncaamb/hierarchy.rb', line 7

def all_attributes
  [:name, :alias, :conferences, :divisions, :teams]
end

#apiObject



37
38
39
# File 'lib/sportradar/api/basketball/ncaamb/hierarchy.rb', line 37

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

#conferencesObject



30
31
32
# File 'lib/sportradar/api/basketball/ncaamb/hierarchy.rb', line 30

def conferences
  divisions.flat_map(&:conferences)
end

#division(code_name) ⇒ Object



24
25
26
# File 'lib/sportradar/api/basketball/ncaamb/hierarchy.rb', line 24

def division(code_name)
  divisions_by_name[code_name]
end

#divisionsObject



21
22
23
# File 'lib/sportradar/api/basketball/ncaamb/hierarchy.rb', line 21

def divisions
  @divisions_hash.values
end

#teamsObject



33
34
35
# File 'lib/sportradar/api/basketball/ncaamb/hierarchy.rb', line 33

def teams
  conferences.flat_map(&:teams)
end