Class: NBA::Game

Inherits:
Object
  • Object
show all
Defined in:
lib/nba/game.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#away_scoreObject (readonly)

Returns the value of attribute away_score.



3
4
5
# File 'lib/nba/game.rb', line 3

def away_score
  @away_score
end

#away_teamObject (readonly)

Returns the value of attribute away_team.



3
4
5
# File 'lib/nba/game.rb', line 3

def away_team
  @away_team
end

#home_scoreObject (readonly)

Returns the value of attribute home_score.



3
4
5
# File 'lib/nba/game.rb', line 3

def home_score
  @home_score
end

#home_teamObject (readonly)

Returns the value of attribute home_team.



3
4
5
# File 'lib/nba/game.rb', line 3

def home_team
  @home_team
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/nba/game.rb', line 3

def status
  @status
end

Class Method Details

.all(date = (Time.now.utc - 5 * 60 * 60).strftime("%Y%m%d")) ⇒ Object

Returns an array of Team objects

Examples:

NBA::Game.all '20140102'
>>  Final/OT  -   Cavaliers     87  :  81    Magic
>>    Final   -      Heat      114  : 123   Warriors
>>    Final   -     Bulls       94  :  82   Celtics
>>    Final   -    Thunder      93  :  95     Nets
>>    Final   -     Spurs      101  : 105    Knicks
>>    Final   -      Suns       91  :  99  Grizzlies
>>    Final   -      Jazz       96  :  87    Bucks
>>    Final   - Trail Blazers  134  : 104   Bobcats
>>    Final   -     Kings      104  : 113    76ers


18
19
20
21
# File 'lib/nba/game.rb', line 18

def self.all(date = (Time.now.utc - 5 * 60 * 60).strftime("%Y%m%d"))
  games = results_to_game(results_from_espn(date))
  print(games)
end

Instance Method Details

#pretty_format(options = {}) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/nba/game.rb', line 23

def pretty_format(options = {})
  self.status.center(options[:status_length].to_i + 1) + " - " + \
    self.home_team.center(options[:home_length].to_i + 1) + " " + \
    (self.home_score =~ /\d/ ? self.home_score.center(4) : "") + " : " + \
    (self.away_score =~ /\d/ ? self.away_score.center(4) : "") + " " + \
    self.away_team.center(options[:away_length].to_i + 1)
end