Class: NBA::LiveGame

Inherits:
Shale::Mapper
  • Object
show all
Defined in:
lib/nba/live_game.rb

Overview

Represents a live game from the NBA Live Data API

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#away_team_cityString

Returns the away team city

Examples:

game.away_team_city #=> "Los Angeles"


132
# File 'lib/nba/live_game.rb', line 132

attribute :away_team_city, Shale::Type::String

#away_team_idInteger

Returns the away team ID

Examples:

game.away_team_id #=> 1610612747


116
# File 'lib/nba/live_game.rb', line 116

attribute :away_team_id, Shale::Type::Integer

#away_team_nameString

Returns the away team name

Examples:

game.away_team_name #=> "Lakers"


124
# File 'lib/nba/live_game.rb', line 124

attribute :away_team_name, Shale::Type::String

#away_team_scoreInteger

Returns the away team score

Examples:

game.away_team_score #=> 108


148
# File 'lib/nba/live_game.rb', line 148

attribute :away_team_score, Shale::Type::Integer

#away_team_tricodeString

Returns the away team tricode

Examples:

game.away_team_tricode #=> "LAL"


140
# File 'lib/nba/live_game.rb', line 140

attribute :away_team_tricode, Shale::Type::String

#game_clockString

Returns the game clock

Examples:

game.game_clock #=> "PT02M30.00S"


52
# File 'lib/nba/live_game.rb', line 52

attribute :game_clock, Shale::Type::String

#game_codeString

Returns the game code

Examples:

game.game_code #=> "20241022/LALGSW"


20
# File 'lib/nba/live_game.rb', line 20

attribute :game_code, Shale::Type::String

#game_etString

Returns the game time in Eastern Time

Examples:

game.game_et #=> "2024-10-22T19:30:00"


68
# File 'lib/nba/live_game.rb', line 68

attribute :game_et, Shale::Type::String

#game_idString

Returns the game ID

Examples:

game.game_id #=> "0022400001"


12
# File 'lib/nba/live_game.rb', line 12

attribute :game_id, Shale::Type::String

#game_statusInteger

Returns the game status (1=scheduled, 2=in progress, 3=final)

Examples:

game.game_status #=> 2


28
# File 'lib/nba/live_game.rb', line 28

attribute :game_status, Shale::Type::Integer

#game_status_textString

Returns the game status text

Examples:

game.game_status_text #=> "Q4 2:30"


36
# File 'lib/nba/live_game.rb', line 36

attribute :game_status_text, Shale::Type::String

#game_time_utcString

Returns the game time in UTC

Examples:

game.game_time_utc #=> "2024-10-22T23:30:00Z"


60
# File 'lib/nba/live_game.rb', line 60

attribute :game_time_utc, Shale::Type::String

#home_team_cityString

Returns the home team city

Examples:

game.home_team_city #=> "Golden State"


92
# File 'lib/nba/live_game.rb', line 92

attribute :home_team_city, Shale::Type::String

#home_team_idInteger

Returns the home team ID

Examples:

game.home_team_id #=> 1610612744


76
# File 'lib/nba/live_game.rb', line 76

attribute :home_team_id, Shale::Type::Integer

#home_team_nameString

Returns the home team name

Examples:

game.home_team_name #=> "Warriors"


84
# File 'lib/nba/live_game.rb', line 84

attribute :home_team_name, Shale::Type::String

#home_team_scoreInteger

Returns the home team score

Examples:

game.home_team_score #=> 112


108
# File 'lib/nba/live_game.rb', line 108

attribute :home_team_score, Shale::Type::Integer

#home_team_tricodeString

Returns the home team tricode

Examples:

game.home_team_tricode #=> "GSW"


100
# File 'lib/nba/live_game.rb', line 100

attribute :home_team_tricode, Shale::Type::String

#periodInteger

Returns the current period

Examples:

game.period #=> 4


44
# File 'lib/nba/live_game.rb', line 44

attribute :period, Shale::Type::Integer

Instance Method Details

#away_scoreInteger

Returns the away team score (alias for CLI compatibility)

Examples:

game.away_score #=> 108


226
227
228
# File 'lib/nba/live_game.rb', line 226

def away_score
  away_team_score
end

#away_teamTeam?

Returns the away team object

Examples:

game.away_team #=> #<NBA::Team>


166
167
168
# File 'lib/nba/live_game.rb', line 166

def away_team
  Teams.find(away_team_id)
end

#final?Boolean

Returns whether the game is final

Examples:

game.final? #=> false


196
197
198
# File 'lib/nba/live_game.rb', line 196

def final?
  game_status.eql?(3)
end

#home_scoreInteger

Returns the home team score (alias for CLI compatibility)

Examples:

game.home_score #=> 112


216
217
218
# File 'lib/nba/live_game.rb', line 216

def home_score
  home_team_score
end

#home_teamTeam?

Returns the home team object

Examples:

game.home_team #=> #<NBA::Team>


156
157
158
# File 'lib/nba/live_game.rb', line 156

def home_team
  Teams.find(home_team_id)
end

#in_progress?Boolean

Returns whether the game is in progress

Examples:

game.in_progress? #=> true


186
187
188
# File 'lib/nba/live_game.rb', line 186

def in_progress?
  game_status.eql?(2)
end

#scheduled?Boolean

Returns whether the game is scheduled

Examples:

game.scheduled? #=> false


176
177
178
# File 'lib/nba/live_game.rb', line 176

def scheduled?
  game_status.eql?(1)
end

#statusString

Returns the game status text (alias for CLI compatibility)

Examples:

game.status #=> "Q4 2:30"


206
207
208
# File 'lib/nba/live_game.rb', line 206

def status
  game_status_text
end