Class: NBA::WinProbabilityPoint

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

Overview

Represents a win probability data point

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#event_numInteger

Returns the event number

Examples:

point.event_num #=> 1

Returns:

  • (Integer)

    the event number



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

attribute :event_num, Shale::Type::Integer

#game_idString

Returns the game ID

Examples:

point.game_id #=> "0022400001"

Returns:

  • (String)

    the game ID



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

attribute :game_id, Shale::Type::String

#home_descriptionString

Returns the home team play description

Examples:

point.home_description #=> "Curry 3PT Shot"

Returns:

  • (String)

    the description



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

attribute :home_description, Shale::Type::String

#home_pctFloat

Returns the home team win probability

Examples:

point.home_pct #=> 0.52

Returns:

  • (Float)

    home win probability (0.0 to 1.0)



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

attribute :home_pct, Shale::Type::Float

#home_ptsInteger

Returns the home team points at this event

Examples:

point.home_pts #=> 25

Returns:

  • (Integer)

    home team points



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

attribute :home_pts, Shale::Type::Integer

#home_score_byInteger

Returns points scored by home team on this event

Examples:

point.home_score_by #=> 2

Returns:

  • (Integer)

    points scored



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

attribute :home_score_by, Shale::Type::Integer

#locationString

Returns the event location

Examples:

point.location #=> "H"

Returns:

  • (String)

    the location



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

attribute :location, Shale::Type::String

#neutral_descriptionString

Returns the neutral play description

Examples:

point.neutral_description #=> "Jump Ball"

Returns:

  • (String)

    the description



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

attribute :neutral_description, Shale::Type::String

#periodInteger

Returns the period

Examples:

point.period #=> 1

Returns:

  • (Integer)

    the period number



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

attribute :period, Shale::Type::Integer

#seconds_remainingInteger

Returns seconds remaining in the period

Examples:

point.seconds_remaining #=> 420

Returns:

  • (Integer)

    seconds remaining



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

attribute :seconds_remaining, Shale::Type::Integer

#visitor_descriptionString

Returns the visitor team play description

Examples:

point.visitor_description #=> "James Layup"

Returns:

  • (String)

    the description



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

attribute :visitor_description, Shale::Type::String

#visitor_pctFloat

Returns the visitor team win probability

Examples:

point.visitor_pct #=> 0.48

Returns:

  • (Float)

    visitor win probability (0.0 to 1.0)



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

attribute :visitor_pct, Shale::Type::Float

#visitor_ptsInteger

Returns the visitor team points at this event

Examples:

point.visitor_pts #=> 23

Returns:

  • (Integer)

    visitor team points



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

attribute :visitor_pts, Shale::Type::Integer

#visitor_score_byInteger

Returns points scored by visitor team on this event

Examples:

point.visitor_score_by #=> 0

Returns:

  • (Integer)

    points scored



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

attribute :visitor_score_by, Shale::Type::Integer

Instance Method Details

#descriptionString?

Returns the description for this event

Examples:

point.description #=> "Curry 3PT Shot"

Returns:

  • (String, nil)

    the description



124
125
126
# File 'lib/nba/win_probability_point.rb', line 124

def description
  home_description || neutral_description || visitor_description
end

#marginInteger?

Returns the score margin (positive = home leading)

Examples:

point.margin #=> 5

Returns:

  • (Integer, nil)

    the score margin, or nil if either score is missing



134
135
136
137
138
# File 'lib/nba/win_probability_point.rb', line 134

def margin
  return nil unless home_pts && visitor_pts

  home_pts - visitor_pts
end