Class: Sportradar::Api::Basketball::Ncaamb::Division

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Data

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

Constructor Details

#initialize(data, **opts) ⇒ Division

Returns a new instance of Division.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/sportradar/api/basketball/ncaamb/division.rb', line 8

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

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

  update(data, **opts)
end

Instance Attribute Details

#aliasObject

Returns the value of attribute alias.



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

def alias
  @alias
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#responseObject

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#conference(code_name) ⇒ Object



28
29
30
# File 'lib/sportradar/api/basketball/ncaamb/division.rb', line 28

def conference(code_name)
  conferences_by_name[code_name]
end

#conferencesObject



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

def conferences
  @conferences_hash.values
end

#conferences_by_nameObject



32
33
34
# File 'lib/sportradar/api/basketball/ncaamb/division.rb', line 32

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

#teamsObject



36
37
38
# File 'lib/sportradar/api/basketball/ncaamb/division.rb', line 36

def teams
  conferences.flat_map(&:teams)
end

#update(data, **opts) ⇒ Object



20
21
22
# File 'lib/sportradar/api/basketball/ncaamb/division.rb', line 20

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