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_city ⇒ String

Returns the away team city

Examples:

game.away_team_city #=> "Los Angeles"

Returns:

  • (String) —

    the away team city



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

attribute :away_team_city, Shale::Type::String

#away_team_id ⇒ Integer

Returns the away team ID

Examples:

game.away_team_id #=> 1610612747

Returns:

  • (Integer) —

    the away team ID



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

attribute :away_team_id, Shale::Type::Integer

#away_team_name ⇒ String

Returns the away team name

Examples:

game.away_team_name #=> "Lakers"

Returns:

  • (String) —

    the away team name



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

attribute :away_team_name, Shale::Type::String

#away_team_score ⇒ Integer

Returns the away team score

Examples:

game.away_team_score #=> 108

Returns:

  • (Integer) —

    the away team score



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

attribute :away_team_score, Shale::Type::Integer

#away_team_tricode ⇒ String

Returns the away team tricode

Examples:

game.away_team_tricode #=> "LAL"

Returns:

  • (String) —

    the away team tricode



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

attribute :away_team_tricode, Shale::Type::String

#game_clock ⇒ String

Returns the game clock

Examples:

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

Returns:

  • (String) —

    the game clock in ISO 8601 duration format



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

attribute :game_clock, Shale::Type::String

#game_code ⇒ String

Returns the game code

Examples:

game.game_code #=> "20241022/LALGSW"

Returns:

  • (String) —

    the game code



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

attribute :game_code, Shale::Type::String

#game_et ⇒ String

Returns the game time in Eastern Time

Examples:

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

Returns:

  • (String) —

    the game time in ET



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

attribute :game_et, Shale::Type::String

#game_id ⇒ String

Returns the game ID

Examples:

game.game_id #=> "0022400001"

Returns:

  • (String) —

    the game ID



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

attribute :game_id, Shale::Type::String

#game_status ⇒ Integer

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

Examples:

game.game_status #=> 2

Returns:

  • (Integer) —

    the game status



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

attribute :game_status, Shale::Type::Integer

#game_status_text ⇒ String

Returns the game status text

Examples:

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

Returns:

  • (String) —

    the game status text



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

attribute :game_status_text, Shale::Type::String

#game_time_utc ⇒ String

Returns the game time in UTC

Examples:

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

Returns:

  • (String) —

    the game time in UTC



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

attribute :game_time_utc, Shale::Type::String

#home_team_city ⇒ String

Returns the home team city

Examples:

game.home_team_city #=> "Golden State"

Returns:

  • (String) —

    the home team city



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

attribute :home_team_city, Shale::Type::String

#home_team_id ⇒ Integer

Returns the home team ID

Examples:

game.home_team_id #=> 1610612744

Returns:

  • (Integer) —

    the home team ID



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

attribute :home_team_id, Shale::Type::Integer

#home_team_name ⇒ String

Returns the home team name

Examples:

game.home_team_name #=> "Warriors"

Returns:

  • (String) —

    the home team name



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

attribute :home_team_name, Shale::Type::String

#home_team_score ⇒ Integer

Returns the home team score

Examples:

game.home_team_score #=> 112

Returns:

  • (Integer) —

    the home team score



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

attribute :home_team_score, Shale::Type::Integer

#home_team_tricode ⇒ String

Returns the home team tricode

Examples:

game.home_team_tricode #=> "GSW"

Returns:

  • (String) —

    the home team tricode



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

attribute :home_team_tricode, Shale::Type::String

#period ⇒ Integer

Returns the current period

Examples:

game.period #=> 4

Returns:

  • (Integer) —

    the current period



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

attribute :period, Shale::Type::Integer

Instance Method Details

#away_score ⇒ Integer

Returns the away team score (alias for CLI compatibility)

Examples:

game.away_score #=> 108

Returns:

  • (Integer) —

    the away team score



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

def away_score
  away_team_score
end

#away_team ⇒ Team?

Returns the away team object

Examples:

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

Returns:

  • (Team, nil) —

    the away team object



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

Returns:

  • (Boolean) —

    true if final



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

def final?
  game_status.eql?(3)
end

#home_score ⇒ Integer

Returns the home team score (alias for CLI compatibility)

Examples:

game.home_score #=> 112

Returns:

  • (Integer) —

    the home team score



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

def home_score
  home_team_score
end

#home_team ⇒ Team?

Returns the home team object

Examples:

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

Returns:

  • (Team, nil) —

    the home team object



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

Returns:

  • (Boolean) —

    true if in progress



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

Returns:

  • (Boolean) —

    true if scheduled



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

def scheduled?
  game_status.eql?(1)
end

#status ⇒ String

Returns the game status text (alias for CLI compatibility)

Examples:

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

Returns:

  • (String) —

    the game status text



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

def status
  game_status_text
end