class Quaker3::Kill

Represents the Kill model extract from Quake 3 Arena log file @author Renan Gigliotti

Constants

DEFAULT_NAME
REGEX_KILLED
REGEX_KILLER
REGEX_KILL_DATA
REGEX_KILL_MODE

Attributes

killed[R]
killer[R]
mode[R]

Public Class Methods

new(line) click to toggle source
# File lib/quaker3/kill.rb, line 16
def initialize(line)
  parse! line
end

Public Instance Methods

to_h() click to toggle source

Generate a hash that represent’s a Kill model @return [Hash] from kill

# File lib/quaker3/kill.rb, line 22
def to_h
  {
    'killer' => @killer,
    'killed' => @killed,
    'mode' => @mode
  }
end

Private Instance Methods

parse!(line) click to toggle source
# File lib/quaker3/kill.rb, line 32
def parse!(line)
  data = line[REGEX_KILL_DATA].strip.split(':')[1].strip

  @killer = parse_name(data[REGEX_KILLER].strip)
  @killed = parse_name(data[REGEX_KILLED].strip)
  @mode = data[REGEX_KILL_MODE].strip
end
parse_name(name) click to toggle source
# File lib/quaker3/kill.rb, line 40
def parse_name(name)
  name.nil? || name.empty? ? DEFAULT_NAME : name
end