class Sportradar::Nhl::Models::Penalty

Public Instance Methods

duration() click to toggle source
# File lib/sportradar/nhl/models/penalty.rb, line 9
def duration
  @attributes.dig('duration')
end
label()
Alias for: penalty_type
minutes() click to toggle source
# File lib/sportradar/nhl/models/penalty.rb, line 13
def minutes
  duration.to_i
end
name() click to toggle source
# File lib/sportradar/nhl/models/penalty.rb, line 17
def name
  ActiveSupport::Inflector.parameterize(penalty_type)
end
penalty_type() click to toggle source
# File lib/sportradar/nhl/models/penalty.rb, line 21
def penalty_type
  @attributes.dig('penalty_type')
end
Also aliased as: label
player_id() click to toggle source
# File lib/sportradar/nhl/models/penalty.rb, line 26
def player_id
  play_player_stats.each do |stat|
    if stat.penalty? && !stat.player_id.nil?
      return stat.player_id
    end
  end

  nil
end
seconds() click to toggle source
# File lib/sportradar/nhl/models/penalty.rb, line 36
def seconds
  minutes * 60
end
team_penalty() click to toggle source
# File lib/sportradar/nhl/models/penalty.rb, line 40
def team_penalty
  false
end
to_h() click to toggle source
# File lib/sportradar/nhl/models/penalty.rb, line 44
def to_h
  {
    id: id,
    game_id: game_id,
    player_id: player_id,
    team_id: team_id,
    minutes: minutes,
    name: name,
    period_number: period_number,
    period_seconds: period_seconds,
    sports_ml_key: id,
    team_penalty: team_penalty,
    time_code: time_code,
    seconds: seconds,
  }
end
to_s() click to toggle source
# File lib/sportradar/nhl/models/penalty.rb, line 5
def to_s
  "#{super} - #{minutes} mins - #{label}"
end