class NbaTodayGem::Game

Attributes

away_team[RW]
date[RW]
home_team[RW]
recap[RW]
score[RW]
status[RW]
top_peformers[RW]
url[RW]
venue[RW]

Public Class Methods

all() click to toggle source
# File lib/nba_today_gem/game.rb, line 31
def self.all
  @@all
end
find(index) click to toggle source
# File lib/nba_today_gem/game.rb, line 27
def self.find(index)
  @@all[index]
end
new() click to toggle source
# File lib/nba_today_gem/game.rb, line 6
def initialize
  @top_peformers = {}
  @@all << self
end
sort_by_total_score() click to toggle source
# File lib/nba_today_gem/game.rb, line 39
def self.sort_by_total_score
  # binding.pry
  NbaTodayGem::Game.all.sort! {|game1, game2| game2.totalscore <=> game1.totalscore}
end

Public Instance Methods

away_team=(away_team) click to toggle source
# File lib/nba_today_gem/game.rb, line 11
def away_team=(away_team)
  if !away_team.is_a?(NbaTodayGem::Team)
    raise TypeError, "must be a Team object"
  else
    @away_team = away_team
  end
end
home_team=(home_team) click to toggle source
# File lib/nba_today_gem/game.rb, line 19
def home_team=(home_team)
  if !home_team.is_a?(NbaTodayGem::Team)
    raise TypeError, "must be a Team object"
  else
    @home_team = home_team
  end
end
totalscore() click to toggle source
# File lib/nba_today_gem/game.rb, line 35
def totalscore
  self.home_team.score[0].to_i + self.away_team.score[0].to_i
end