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(xml, conference = nil, division = nil) ⇒ Team



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sports_data_api/nba/team.rb', line 7

def initialize(xml, conference = nil, division = nil)
  xml = xml.first if xml.is_a? Nokogiri::XML::NodeSet
  if xml.is_a? Nokogiri::XML::Element
    @id = xml['id']
    @name = xml['name']
    @market = xml['market']
    @alias = xml['alias']
    @points = xml['points'] ? xml['points'].to_i : nil
    @conference = conference
    @division = division
    @players = xml.xpath("players/player").map do |player_xml|
      Player.new(player_xml)
    end
  end
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

#playersObject (readonly)

Returns the value of attribute players.



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

def players
  @players
end

#pointsObject (readonly)

Returns the value of attribute points.



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

def points
  @points
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



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sports_data_api/nba/team.rb', line 25

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