Class: SportsDataApi::Nhl::Team
- Inherits:
-
Object
- Object
- SportsDataApi::Nhl::Team
- Defined in:
- lib/sports_data_api/nhl/team.rb
Instance Attribute Summary collapse
-
#alias ⇒ Object
readonly
Returns the value of attribute alias.
-
#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.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compare the Team with another team.
- #conference ⇒ Object
- #division ⇒ Object
-
#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
Returns a new instance of Team.
6 7 8 9 10 11 12 13 14 |
# File 'lib/sports_data_api/nhl/team.rb', line 6 def initialize(json, conference = nil, division = nil) @json = json @id = json['id'] @name = json['name'] @market = json['market'] @alias = json['alias'] @conference = conference @division = division end |
Instance Attribute Details
#alias ⇒ Object (readonly)
Returns the value of attribute alias.
4 5 6 |
# File 'lib/sports_data_api/nhl/team.rb', line 4 def alias @alias end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/sports_data_api/nhl/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/nhl/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/nhl/team.rb', line 4 def name @name end |
Instance Method Details
#==(other) ⇒ Object
Compare the Team with another team
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/sports_data_api/nhl/team.rb', line 43 def ==(other) return false if id.nil? if other.is_a? SportsDataApi::Nhl::Team other.id && id === other.id elsif other.is_a? Symbol id.to_sym === other else super(other) end end |
#conference ⇒ Object
16 17 18 |
# File 'lib/sports_data_api/nhl/team.rb', line 16 def conference @conference ||= json.fetch('conference', {})['alias'] end |
#division ⇒ Object
20 21 22 |
# File 'lib/sports_data_api/nhl/team.rb', line 20 def division @division ||= json.fetch('division', {})['alias'] end |
#players ⇒ Object
29 30 31 32 33 34 |
# File 'lib/sports_data_api/nhl/team.rb', line 29 def players return [] if json['players'].nil? @players ||= json['players'].map do |player_json| Player.new(player_json) end end |
#points ⇒ Object
24 25 26 27 |
# File 'lib/sports_data_api/nhl/team.rb', line 24 def points return unless json['points'] json['points'].to_i end |
#venue ⇒ Object
36 37 38 39 |
# File 'lib/sports_data_api/nhl/team.rb', line 36 def venue return if json['venue'].nil? @venue ||= Venue.new(json['venue']) end |