Class: Sportradar::Nhl::Models::ScoringPlay

Inherits:
Event
  • Object
show all
Defined in:
lib/sportradar/nhl/models/scoring_play.rb

Constant Summary

Constants inherited from Event

Event::EVENT_TYPES, Event::PENALTY_TYPES, Event::PLAY_TYPES, Event::SCORING_PLAY_TYPES, Event::STOPPAGE_TYPES

Instance Method Summary collapse

Methods inherited from Event

#clock, #clock_secs, #coordinate_x, #coordinate_y, #coordinates, #coordinates?, #description, #event_type, #game_id, #has_team?, #id, #initialize, #official, #penalty?, #period, #period_abbreviation, #period_id, #period_number, #period_sequence, #period_type, #play?, #play_player_stats, #scoring_play?, #scoring_players, #statistics, #stoppage?, #strength, #team, #team_goal_side, #team_id, #time_code, #to_s, #updated_at, #wall_clock, #zone

Constructor Details

This class inherits a constructor from Sportradar::Nhl::Models::Event

Instance Method Details

#empty_netObject



42
43
44
# File 'lib/sportradar/nhl/models/scoring_play.rb', line 42

def empty_net
  event_type == 'emptynetgoal'
end

#empty_net?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/sportradar/nhl/models/scoring_play.rb', line 46

def empty_net?
  empty_net
end

#penalty_goalObject



50
51
52
# File 'lib/sportradar/nhl/models/scoring_play.rb', line 50

def penalty_goal
  event_type == 'penaltygoal'
end

#penalty_goal?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/sportradar/nhl/models/scoring_play.rb', line 54

def penalty_goal?
  penalty_goal
end

#pointsObject



5
6
7
# File 'lib/sportradar/nhl/models/scoring_play.rb', line 5

def points
  1
end

#scored_atObject



9
10
11
# File 'lib/sportradar/nhl/models/scoring_play.rb', line 9

def scored_at
  wall_clock
end

#scoring_howObject



38
39
40
# File 'lib/sportradar/nhl/models/scoring_play.rb', line 38

def scoring_how
  event_type
end

#scoring_methodObject



13
14
15
16
17
18
19
# File 'lib/sportradar/nhl/models/scoring_play.rb', line 13

def scoring_method
  if empty_net? || penalty_goal? || shootout_goal?
    'goal'
  else
    event_type
  end
end

#scoring_typeObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sportradar/nhl/models/scoring_play.rb', line 21

def scoring_type
  case strength
  when 'even'
    'ev'
  when 'powerplay'
    'pp'
  when 'shorthanded'
    'sh'
  else
    if shootout_goal?
      'so'
    else
      strength
    end
  end
end

#shootout_goal?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/sportradar/nhl/models/scoring_play.rb', line 58

def shootout_goal?
  event_type == 'shootoutgoal'
end

#to_hObject



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/sportradar/nhl/models/scoring_play.rb', line 62

def to_h
  {
    id: id,
    game_id: game_id,
    points: points,
    scored_at: scored_at,
    scoring_method: scoring_method,
    scoring_type: scoring_type,
    empty_net: empty_net,
  }.compact
end