Class: Sportradar::Api::Basketball::Nba::Team

Inherits:
Team
  • Object
show all
Defined in:
lib/sportradar/api/basketball/nba/team.rb

Instance Attribute Summary

Attributes inherited from Team

#alias, #full_name, #id, #market, #name, #player_stats, #records, #response, #seed, #team_stats, #venue

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Team

#add_game, #games, #get_roster, #get_season_stats, #ingest_roster, #ingest_season_stats, #initialize, #parse_players, #parse_records, #parse_season_stats, #path_base, #path_base_stats, #path_roster, #path_season_stats, #players, #profile, #queue_roster, #queue_season_stats, #record, #update, #update_player_stats

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

This class inherits a constructor from Sportradar::Api::Basketball::Team

Class Method Details

.allObject



21
22
23
# File 'lib/sportradar/api/basketball/nba/team.rb', line 21

def self.all
  @all_hash.values
end

.new(data, **opts) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sportradar/api/basketball/nba/team.rb', line 9

def self.new(data, **opts)
  existing = @all_hash[data['id']]
  if existing
    existing.update(data, **opts)
    existing
  else
    # unless data['id']
    #   data.merge!(data.delete('team')) if data['team']
    # end
    @all_hash[data['id']] = super
  end
end

Instance Method Details

#apiObject



29
30
31
# File 'lib/sportradar/api/basketball/nba/team.rb', line 29

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

#handle_names(data) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/sportradar/api/basketball/nba/team.rb', line 33

def handle_names(data)
  # need to do some more work here
  @name = data['name'] if data['name']
  if data['name'] && !data.key?('market')
    @full_name = data['name']
    if @full_name.split.size > 1
      if @full_name.include? 'Blazers'
        @market = 'Portland'
        @name = 'Trail Blazers'
        @full_name = 'Portland Trail Blazers'
      else
        @market = @full_name.split[0..-2].join(' ')
        @name = @full_name.split.last
      end
    end
  elsif data['name'] && data['market']
    @market = data['market']
    @full_name = [@market, data['name']].join(' ')
  end
end

#player_classObject



25
26
27
# File 'lib/sportradar/api/basketball/nba/team.rb', line 25

def player_class
  Player
end