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.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compare the Team with another team.
-
#initialize(json, conference = nil, division = nil) ⇒ Team
constructor
A new instance of Team.
- #players ⇒ Object
- #points ⇒ Object
- #venue ⇒ Object
Constructor Details
#initialize(json, conference = nil, division = nil) ⇒ 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
#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 |
#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
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 |
#players ⇒ Object
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 |
#points ⇒ Object
18 19 20 |
# File 'lib/sports_data_api/nba/team.rb', line 18 def points @points ||= json['points'] ? json['points'].to_i : nil end |
#venue ⇒ Object
27 28 29 |
# File 'lib/sports_data_api/nba/team.rb', line 27 def venue @venue ||= Venue.new(json['venue']) if json['venue'] end |