Class: TF2LineParser::Events::KilledObject
- Defined in:
- lib/tf2_line_parser/events/killed_object.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#objectowner ⇒ Object
readonly
Returns the value of attribute objectowner.
-
#player ⇒ Object
readonly
Returns the value of attribute player.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#weapon ⇒ Object
readonly
Returns the value of attribute weapon.
Attributes inherited from Event
#airshot, #cap_name, #cap_number, #customkill, #healing, #item, #length, #message, #method, #role, #score, #target, #team, #type, #ubercharge, #unknown, #value
Class Method Summary collapse
- .attributes ⇒ Object
- .regex ⇒ Object
- .regex_attacker_position ⇒ Object
- .regex_object_info ⇒ Object
- .regex_results(matched_line) ⇒ Object
Instance Method Summary collapse
-
#initialize(time, player_name, player_uid, player_steam_id, player_team, object, weapon, objectowner_name, objectowner_uid, objectowner_steam_id, objectowner_team) ⇒ KilledObject
constructor
A new instance of KilledObject.
Methods inherited from Event
parse_player_section, parse_target_section, #parse_time, regex_cap, regex_console, regex_message, regex_player, regex_target, regex_time, time_format, types
Constructor Details
#initialize(time, player_name, player_uid, player_steam_id, player_team, object, weapon, objectowner_name, objectowner_uid, objectowner_steam_id, objectowner_team) ⇒ KilledObject
Returns a new instance of KilledObject.
45 46 47 48 49 50 51 |
# File 'lib/tf2_line_parser/events/killed_object.rb', line 45 def initialize(time, player_name, player_uid, player_steam_id, player_team, object, weapon, objectowner_name, objectowner_uid, objectowner_steam_id, objectowner_team) @time = parse_time(time) @player = Player.new(player_name, player_uid, player_steam_id, player_team) @object = object @weapon = weapon @objectowner = Player.new(objectowner_name, objectowner_uid, objectowner_steam_id, objectowner_team) end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
4 5 6 |
# File 'lib/tf2_line_parser/events/killed_object.rb', line 4 def object @object end |
#objectowner ⇒ Object (readonly)
Returns the value of attribute objectowner.
4 5 6 |
# File 'lib/tf2_line_parser/events/killed_object.rb', line 4 def objectowner @objectowner end |
#player ⇒ Object (readonly)
Returns the value of attribute player.
4 5 6 |
# File 'lib/tf2_line_parser/events/killed_object.rb', line 4 def player @player end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
4 5 6 |
# File 'lib/tf2_line_parser/events/killed_object.rb', line 4 def time @time end |
#weapon ⇒ Object (readonly)
Returns the value of attribute weapon.
4 5 6 |
# File 'lib/tf2_line_parser/events/killed_object.rb', line 4 def weapon @weapon end |
Class Method Details
.attributes ⇒ Object
18 19 20 |
# File 'lib/tf2_line_parser/events/killed_object.rb', line 18 def self.attributes @attributes ||= %i[time player_section object weapon objectowner_section] end |
.regex ⇒ Object
6 7 8 |
# File 'lib/tf2_line_parser/events/killed_object.rb', line 6 def self.regex @regex ||= /#{regex_time} #{regex_player} triggered "killedobject" #{regex_object_info}#{regex_attacker_position}?/.freeze end |
.regex_attacker_position ⇒ Object
14 15 16 |
# File 'lib/tf2_line_parser/events/killed_object.rb', line 14 def self.regex_attacker_position @regex_attacker_position ||= / \(attacker_position "[^"]+"\)/ end |
.regex_object_info ⇒ Object
10 11 12 |
# File 'lib/tf2_line_parser/events/killed_object.rb', line 10 def self.regex_object_info @regex_object_info ||= '\(object "(?\'object\'[^"]+)"\) \(weapon "(?\'weapon\'[^"]+)"\) \(objectowner "(?\'objectowner_section\'.*?)"\)' end |
.regex_results(matched_line) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/tf2_line_parser/events/killed_object.rb', line 22 def self.regex_results(matched_line) out = [] attributes.each do |attribute| case attribute when :player_section if matched_line['player_section'] out.concat(parse_player_section(matched_line['player_section'])) else out.concat([nil, nil, nil, nil]) end when :objectowner_section if matched_line['objectowner_section'] out.concat(parse_player_section(matched_line['objectowner_section'])) else out.concat([nil, nil, nil, nil]) end else out << matched_line[attribute] end end out end |