Class: SportsDataApi::Nba::Team
- Inherits:
-
Object
- Object
- SportsDataApi::Nba::Team
- Defined in:
- lib/sports_data_api/nba/team.rb
Instance Attribute Summary collapse
-
#alias ⇒ Object
readonly
Returns the value of attribute alias.
-
#conference ⇒ Object
readonly
Returns the value of attribute conference.
-
#division ⇒ Object
readonly
Returns the value of attribute division.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#market ⇒ Object
readonly
Returns the value of attribute market.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#players ⇒ Object
readonly
Returns the value of attribute players.
-
#points ⇒ Object
readonly
Returns the value of attribute points.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compare the Team with another team.
-
#initialize(xml, conference = nil, division = nil) ⇒ Team
constructor
A new instance of Team.
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
#alias ⇒ Object (readonly)
Returns the value of attribute alias.
4 5 6 |
# File 'lib/sports_data_api/nba/team.rb', line 4 def alias @alias end |
#conference ⇒ Object (readonly)
Returns the value of attribute conference.
4 5 6 |
# File 'lib/sports_data_api/nba/team.rb', line 4 def conference @conference end |
#division ⇒ Object (readonly)
Returns the value of attribute division.
4 5 6 |
# File 'lib/sports_data_api/nba/team.rb', line 4 def division @division end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/sports_data_api/nba/team.rb', line 4 def id @id end |
#market ⇒ Object (readonly)
Returns the value of attribute market.
4 5 6 |
# File 'lib/sports_data_api/nba/team.rb', line 4 def market @market end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/sports_data_api/nba/team.rb', line 4 def name @name end |
#players ⇒ Object (readonly)
Returns the value of attribute players.
4 5 6 |
# File 'lib/sports_data_api/nba/team.rb', line 4 def players @players end |
#points ⇒ Object (readonly)
Returns the value of attribute points.
4 5 6 |
# File 'lib/sports_data_api/nba/team.rb', line 4 def points @points end |
#stats ⇒ Object (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 |