Class: Regulos::CombatLog::Event::Base
- Inherits:
-
Object
- Object
- Regulos::CombatLog::Event::Base
show all
- Defined in:
- lib/regulos/combat_log/event/base.rb
Overview
An event represents a row in the combat log.
Direct Known Subclasses
Affliction, AttackHit, AttackMiss, BeginCast, BuffFade, BuffGain, CriticalHeal, CriticalHit, DamageOverTime, Death, Dissipate, Dodge, EndCast, FallDamage, Heal, Immune, Interrupt, ManaGain, Parry, Resist, Unknown, UnknownDeath
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes) ⇒ Base
Returns a new instance of Base.
32
33
34
|
# File 'lib/regulos/combat_log/event/base.rb', line 32
def initialize(attributes)
process attributes
end
|
Class Method Details
.determine_event_type(hash) ⇒ Object
101
102
103
104
|
# File 'lib/regulos/combat_log/event/base.rb', line 101
def determine_event_type hash
kind = CODES.invert.fetch(hash[:action_code]){ "Unknown" }
Regulos::CombatLog::Event.const_get "#{kind}"
end
|
.sanitize(hash) ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/regulos/combat_log/event/base.rb', line 89
def sanitize hash
hash.each_pair do |k,v|
v.to_s.strip! v.to_s.gsub! /[,\(\)]\Z/, '' v.to_s.gsub! /\A[,\(\)]/, '' v.to_s.strip! hash[k] = v
end
hash
end
|
.which(row) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/regulos/combat_log/event/base.rb', line 67
def which(row)
require "strscan"
s = StringScanner.new row
entity_regex = /\s[A-Z]=[A-Z]#[A-Z]=[A-Z]#\d+?\s,/
e = {}
e[:time] = s.scan(/\d{2}:\d{2}:\d{2}:\s\(/) e[:action_code] = s.scan(/\s\d+?\s,/) e[:origin] = s.scan entity_regex
e[:target] = s.scan entity_regex
e[:pet_origin] = s.scan entity_regex e[:pet_target] = s.scan entity_regex e[:origin_name] = s.scan /\s[A-Za-z\s\-]+?\s,/
e[:target_name] = s.scan /\s[A-Za-z\s\-]+?\s,/
e[:output] = s.scan /\s\d+?\s,/ e[:spell_id] = s.scan /\s\d+?\s,/ e[:spell_name] = s.scan /\s[A-Za-z\-\s]+?\s\)/ e[:full_message] = s.scan /\s(.*)+\Z/ e = sanitize(e)
determine_event_type(e).new e
end
|
Instance Method Details
#buff? ⇒ Boolean
52
53
54
|
# File 'lib/regulos/combat_log/event/base.rb', line 52
def buff?
code == :BuffGain
end
|
#code ⇒ Object
40
41
42
|
# File 'lib/regulos/combat_log/event/base.rb', line 40
def code
CODES.invert[ action_code ]
end
|
#debuff? ⇒ Boolean
56
57
58
|
# File 'lib/regulos/combat_log/event/base.rb', line 56
def debuff?
code == :Affliction
end
|
#heal? ⇒ Boolean
44
45
46
|
# File 'lib/regulos/combat_log/event/base.rb', line 44
def heal?
full_message =~ /heals/
end
|
#inspect ⇒ Object
36
37
38
|
# File 'lib/regulos/combat_log/event/base.rb', line 36
def inspect
"<#{self.class}>"
end
|
#overheal? ⇒ Boolean
48
49
50
|
# File 'lib/regulos/combat_log/event/base.rb', line 48
def overheal?
full_message =~ /\d\soverheal/
end
|
#process(attributes) ⇒ Object
60
61
62
|
# File 'lib/regulos/combat_log/event/base.rb', line 60
def process attributes
attributes.each_pair{|k,v| self.class.send(:attr_reader, k); instance_variable_set("@#{k}", v) }
end
|