Class: Sportradar::Api::Football::Ncaafb::Conference

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/football/ncaafb/conference.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) ⇒ Conference

Returns a new instance of Conference.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sportradar/api/football/ncaafb/conference.rb', line 8

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

  @id    = data["id"]
  @name  = data["name"]
  @alias = data["alias"] || data["id"]
  @teams_hash = {}
  @subdivisions_hash = {}
  @assigned_teams = nil
  # binding.pry

  create_data(@teams_hash, data["teams"], klass: Team, conference: self, api: @api) if data["teams"]
  create_data(@subdivisions_hash, data["subdivisions"], klass: Subdivision, conference: self, api: @api) if data["subdivisions"]
end

Instance Attribute Details

#aliasObject

Returns the value of attribute alias.



6
7
8
# File 'lib/sportradar/api/football/ncaafb/conference.rb', line 6

def alias
  @alias
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/sportradar/api/football/ncaafb/conference.rb', line 6

def id
  @id
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/sportradar/api/football/ncaafb/conference.rb', line 6

def name
  @name
end

#responseObject

Returns the value of attribute response.



6
7
8
# File 'lib/sportradar/api/football/ncaafb/conference.rb', line 6

def response
  @response
end

Instance Method Details

#conferencesObject



44
45
46
# File 'lib/sportradar/api/football/ncaafb/conference.rb', line 44

def conferences
  teams.flat_map(&:conferences)
end

#team(code_name) ⇒ Object



38
39
40
# File 'lib/sportradar/api/football/ncaafb/conference.rb', line 38

def team(code_name)
  teams_by_name[code_name]
end

#teamsObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sportradar/api/football/ncaafb/conference.rb', line 24

def teams
  @assigned_teams || begin
    if !@subdivisions_hash.empty?
      @subdivisions_hash.each_value.flat_map(&:teams)
    elsif !@teams_hash.empty?
      @teams_hash.values
    else
      []
    end
  end
end

#teams=(array) ⇒ Object



35
36
37
# File 'lib/sportradar/api/football/ncaafb/conference.rb', line 35

def teams=(array)
  @assigned_teams = array
end