Class: Sportradar::Api::Basketball::Ncaamb::Season

Inherits:
Season
  • Object
show all
Defined in:
lib/sportradar/api/basketball/ncaamb/season.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) ⇒ Season

Returns a new instance of Season.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sportradar/api/basketball/ncaamb/season.rb', line 8

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

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

  @year     = data.dig('season', 'year')
  @type     = data.dig('season', 'type')

  @games_hash = {}
  @tournaments_hash = {}
  update_games(data['games'])             if data['games']
  update_tournaments(data['tournaments']) if data['tournaments']
end

Instance Attribute Details

#aliasObject

Returns the value of attribute alias.



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

def alias
  @alias
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#responseObject

Returns the value of attribute response.



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

def response
  @response
end

#yearObject

Returns the value of attribute year.



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

def year
  @year
end

Instance Method Details

#gamesObject



25
26
27
# File 'lib/sportradar/api/basketball/ncaamb/season.rb', line 25

def games
  @games_hash.values
end

#tournament(id) ⇒ Object



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

def tournament(id)
  @tournaments_hash[id]
end

#tournamentsObject



29
30
31
# File 'lib/sportradar/api/basketball/ncaamb/season.rb', line 29

def tournaments
  @tournaments_hash.values
end

#update_games(data) ⇒ Object



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

def update_games(data)
  create_data(@games_hash, data, klass: Game, api: @api, season: self)
end

#update_tournaments(data) ⇒ Object



41
42
43
# File 'lib/sportradar/api/basketball/ncaamb/season.rb', line 41

def update_tournaments(data)
  create_data(@tournaments_hash, data, klass: Tournament, api: @api, season: self)
end