Class: Quaker3::Kill

Inherits:
Object
  • Object
show all
Defined in:
lib/quaker3/kill.rb

Overview

Represents the Kill model extract from Quake 3 Arena log file

Author:

  • Renan Gigliotti

Constant Summary collapse

REGEX_KILL_DATA =
/(?<=Kill:).*/.freeze
REGEX_KILLER =
/(.*)(?=killed)/.freeze
REGEX_KILLED =
/(?<=killed)(.*)(?=by)/.freeze
REGEX_KILL_MODE =
/(?<=by).*/.freeze
DEFAULT_NAME =
'(player)'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ Kill

Returns a new instance of Kill.



16
17
18
# File 'lib/quaker3/kill.rb', line 16

def initialize(line)
  parse! line
end

Instance Attribute Details

#killedObject (readonly)

Returns the value of attribute killed.



7
8
9
# File 'lib/quaker3/kill.rb', line 7

def killed
  @killed
end

#killerObject (readonly)

Returns the value of attribute killer.



7
8
9
# File 'lib/quaker3/kill.rb', line 7

def killer
  @killer
end

#modeObject (readonly)

Returns the value of attribute mode.



7
8
9
# File 'lib/quaker3/kill.rb', line 7

def mode
  @mode
end

Instance Method Details

#to_hHash

Generate a hash that represent’s a Kill model

Returns:

  • (Hash)

    from kill



22
23
24
25
26
27
28
# File 'lib/quaker3/kill.rb', line 22

def to_h
  {
    'killer' => @killer,
    'killed' => @killed,
    'mode' => @mode
  }
end