class SportsDataApi::Nhl::Team

Attributes

alias[R]
id[R]
json[R]
market[R]
name[R]

Public Class Methods

new(json, conference = nil, division = nil) click to toggle source
# 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

Public Instance Methods

==(other) click to toggle source

Compare the Team with another team

Calls superclass method
# 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() click to toggle source
# File lib/sports_data_api/nhl/team.rb, line 16
def conference
  @conference ||= json.fetch('conference', {})['alias']
end
division() click to toggle source
# File lib/sports_data_api/nhl/team.rb, line 20
def division
  @division ||= json.fetch('division', {})['alias']
end
players() click to toggle source
# 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() click to toggle source
# File lib/sports_data_api/nhl/team.rb, line 24
def points
  return unless json['points']
  json['points'].to_i
end
venue() click to toggle source
# File lib/sports_data_api/nhl/team.rb, line 36
def venue
  return if json['venue'].nil?
  @venue ||= Venue.new(json['venue'])
end