Class: SportsDataApi::Nba::Team

Inherits:
Object
  • Object
show all
Defined in:
lib/sports_data_api/nba/team.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json, conference = nil, division = nil) ⇒ Team

Returns a new instance of Team.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sports_data_api/nba/team.rb', line 6

def initialize(json, conference = nil, division = nil)
  @conference = conference
  @division = division
  @id = json['id']
  @name = json['name']
  @market = json['market']
  @alias = json['alias']
  @points = json['points']
  @alias = json['alias']
  @json = json
end

Instance Attribute Details

#aliasObject (readonly)

Returns the value of attribute alias.



4
5
6
# File 'lib/sports_data_api/nba/team.rb', line 4

def alias
  @alias
end

#conferenceObject (readonly)

Returns the value of attribute conference.



4
5
6
# File 'lib/sports_data_api/nba/team.rb', line 4

def conference
  @conference
end

#divisionObject (readonly)

Returns the value of attribute division.



4
5
6
# File 'lib/sports_data_api/nba/team.rb', line 4

def division
  @division
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/sports_data_api/nba/team.rb', line 4

def id
  @id
end

#marketObject (readonly)

Returns the value of attribute market.



4
5
6
# File 'lib/sports_data_api/nba/team.rb', line 4

def market
  @market
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/sports_data_api/nba/team.rb', line 4

def name
  @name
end

#statsObject (readonly)

Returns the value of attribute stats.



4
5
6
# File 'lib/sports_data_api/nba/team.rb', line 4

def stats
  @stats
end

Instance Method Details

#==(other) ⇒ Object

Compare the Team with another team



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sports_data_api/nba/team.rb', line 33

def ==(other)
  # Must have an id to compare
  return false if id.nil?

  if other.is_a? SportsDataApi::Nba::Team
    other.id && id === other.id
  elsif other.is_a? Symbol
    id.to_sym === other
  else
    super(other)
  end
end

#playersObject



22
23
24
25
# File 'lib/sports_data_api/nba/team.rb', line 22

def players
  return [] if json['players'].nil? || json['players'].empty?
  @players ||= json['players'].map { |x| Player.new(x) }
end

#pointsObject



18
19
20
# File 'lib/sports_data_api/nba/team.rb', line 18

def points
  @points ||= json['points'] ? json['points'].to_i : nil
end

#venueObject



27
28
29
# File 'lib/sports_data_api/nba/team.rb', line 27

def venue
  @venue ||= Venue.new(json['venue']) if json['venue']
end