Class: RMuh::RPT::Log::Parsers::UnitedOperationsLog

Inherits:
Base
  • Object
show all
Extended by:
Util::UnitedOperations, Util::UnitedOperationsLog
Includes:
Util::UnitedOperations, Util::UnitedOperationsLog
Defined in:
lib/rmuh/rpt/log/parsers/unitedoperationslog.rb

Overview

This is the UnitedOperations Log parser class. It separates the log in to an array of Hashes, one for each log line.

This can be used to rebuild the log file, from metadata alone.

It extends RMuh::RPT::Log::Parsers::Base

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::UnitedOperations

__check_match_arg, __guid_add_data, __guid_data_base, __line_modifiers, __modifiers, __parse_nearby_players, add_guid!, guid_keys, m_to_h, validate_bool_opt, validate_timezone, zulu!

Constructor Details

#initialize(opts = {}) ⇒ UnitedOperationsLog

This builds the object. There are three optional args for the Hash:

  • :chat – should chat lines be included?

  • :to_zulu – convert timestamp to zulu

  • :timezone – specify the server timezone

– TODO: Make this use an auto hash to instance variable function ++



46
47
48
49
50
51
# File 'lib/rmuh/rpt/log/parsers/unitedoperationslog.rb', line 46

def initialize(opts = {})
  self.class.validate_opts(opts)
  @include_chat = opts.fetch(:chat, false)
  @to_zulu = opts.fetch(:to_zulu, true)
  @timezone = opts.fetch(:timezone, UO_TZ)
end

Class Method Details

.validate_opts(opts) ⇒ Object

Validate the options that are passed in as arg 1 to the new() function

This raises ArgumentError if something doesn’t pass



30
31
32
33
34
35
36
37
# File 'lib/rmuh/rpt/log/parsers/unitedoperationslog.rb', line 30

def self.validate_opts(opts)
  fail(
    ArgumentError, 'arg 1 should be an instance of Hash'
  ) unless opts.is_a?(Hash)
  validate_bool_opt(opts, :to_zulu)
  validate_timezone(opts)
  validate_bool_opt(opts, :chat)
end

Instance Method Details

#parse(loglines) ⇒ Object



53
54
55
56
57
58
# File 'lib/rmuh/rpt/log/parsers/unitedoperationslog.rb', line 53

def parse(loglines)
  unless loglines.is_a?(Array)
    fail ArgumentError, 'arg 1 must be an Array object'
  end
  regex_matches(loglines)
end