Class: Sportradar::Nba::Models::PlayPlayerStat

Inherits:
Object
  • Object
show all
Defined in:
lib/sportradar/nba/models/play_player_stat.rb

Direct Known Subclasses

ScoringPlayer

Instance Method Summary collapse

Constructor Details

#initialize(event:, attributes:) ⇒ PlayPlayerStat

Returns a new instance of PlayPlayerStat.



5
6
7
8
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 5

def initialize(event:, attributes:)
  @event = event
  @attributes = attributes
end

Instance Method Details

#clockObject



57
58
59
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 57

def clock
  @event.clock
end

#defensive_rebound?Boolean

Returns:

  • (Boolean)


137
138
139
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 137

def defensive_rebound?
  rebound_type == 'defensive'
end

#descriptionObject



29
30
31
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 29

def description
  @event.description
end

#dunk?Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 173

def dunk?
  shot_type == 'dunk'
end

#eventObject



21
22
23
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 21

def event
  @event
end

#event_idObject



25
26
27
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 25

def event_id
  @event.id
end

#free_throw?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 121

def free_throw?
  type == 'freethrow'
end

#free_throw_typeObject



117
118
119
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 117

def free_throw_type
  @attributes.dig('free_throw_type')
end

#full_nameObject



73
74
75
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 73

def full_name
  player.dig('full_name')
end

#hook?Boolean

Returns:

  • (Boolean)


177
178
179
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 177

def hook?
  shot_type == 'hook shot'
end

#jerseyObject



69
70
71
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 69

def jersey
  player.dig('jersey')
end

#jump_shot?Boolean

Returns:

  • (Boolean)


165
166
167
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 165

def jump_shot?
  shot_type == 'jump shot'
end

#layup?Boolean

Returns:

  • (Boolean)


169
170
171
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 169

def layup?
  shot_type == 'layup'
end

#made?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 113

def made?
  @attributes.dig('made') == true
end

#offensive_rebound?Boolean

Returns:

  • (Boolean)


141
142
143
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 141

def offensive_rebound?
  rebound_type == 'offensive'
end

#playerObject



61
62
63
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 61

def player
  @attributes.dig('player') || {}
end

#player_idObject



65
66
67
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 65

def player_id
  player.dig('id')
end

#pointsObject



133
134
135
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 133

def points
  @attributes.dig('points')
end

#quarterObject



33
34
35
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 33

def quarter
  @event.quarter
end

#quarter_abbreviationObject



41
42
43
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 41

def quarter_abbreviation
  quarter.abbreviation
end

#quarter_idObject



37
38
39
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 37

def quarter_id
  quarter.id
end

#quarter_numberObject



45
46
47
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 45

def quarter_number
  quarter.number
end

#quarter_sequenceObject



49
50
51
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 49

def quarter_sequence
  quarter.sequence
end

#quarter_typeObject



53
54
55
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 53

def quarter_type
  quarter.type
end

#rebound_typeObject



145
146
147
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 145

def rebound_type
  @attributes.dig('rebound_type')
end

#regular_free_throw?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 125

def regular_free_throw?
  free_throw_type == 'regular'
end

#shot_typeObject



149
150
151
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 149

def shot_type
  @attributes.dig('shot_type')
end

#shot_type_descObject



153
154
155
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 153

def shot_type_desc
  @attributes.dig('shot_type_desc')
end

#statObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 93

def stat
  {
    player_id: player_id,
    team_id: team_id,
    made: made?,
    free_throw_type: free_throw_type,
    free_throw: free_throw?,
    regular_free_throw: regular_free_throw?,
    technical_free_throw: technical_free_throw?,
    points: points,
    rebound_type: rebound_type,
    defensive_rebound: defensive_rebound?,
    offensive_rebound: offensive_rebound?,
    shot_type: shot_type,
    shot_type_desc: shot_type_desc,
    three_point_shot: three_point_shot?,
    type: type,
  }.compact
end

#teamObject



77
78
79
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 77

def team
  @attributes.dig('team') || {}
end

#team_idObject



81
82
83
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 81

def team_id
  team.dig('id')
end

#team_marketObject



85
86
87
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 85

def team_market
  team.dig('market')
end

#team_nameObject



89
90
91
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 89

def team_name
  team.dig('name')
end

#technical_free_throw?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 129

def technical_free_throw?
  free_throw_type == 'technical'
end

#three_point_shot?Boolean

Returns:

  • (Boolean)


157
158
159
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 157

def three_point_shot?
  @attributes.dig('three_point_shot') == true
end

#tip?Boolean

Returns:

  • (Boolean)


181
182
183
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 181

def tip?
  shot_type == 'tip shot'
end

#to_sObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 10

def to_s
  [
    quarter_abbreviation,
    clock,
    description,
    team_name,
    full_name,
    stat,
  ].join(' ')
end

#typeObject



161
162
163
# File 'lib/sportradar/nba/models/play_player_stat.rb', line 161

def type
  @attributes.dig('type')
end