Class: RMuh::RPT::Log::Parsers::UnitedOperationsRPT
- Extended by:
- Util::UnitedOperations
- Includes:
- Util::UnitedOperations, Util::UnitedOperationsRPT
- Defined in:
- lib/rmuh/rpt/log/parsers/unitedoperationsrpt.rb
Overview
This is the UnitedOperations parser class. This separates the UnitedOperations log lines in to their respective Hashes
This can be used to rebuild the log file, from metadata alone.
It extends RMuh::RPT::Log::Parsers::Base
Class Method Summary collapse
-
.validate_opts(opts) ⇒ Object
This is used to validate the options passed in to new() Will throw ArgumentError if things aren’t right.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ UnitedOperationsRPT
constructor
This is the initializer for the whole object.
-
#parse(loglines) ⇒ Object
Parse the Array object which is the lines from the log.
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 = {}) ⇒ UnitedOperationsRPT
This is the initializer for the whole object. There are two valid options for this class: :to_zulu – convert the timestamp to zulu and add iso8601 and dtg
timestamp -- this defaults to true
:timezone – specifies the server’s timezone from the tz database
this defaults to the UO timezone
– TODO: Convert this to use an auto hash to instance variable ++
43 44 45 46 47 48 |
# File 'lib/rmuh/rpt/log/parsers/unitedoperationsrpt.rb', line 43 def initialize(opts = {}) self.class.validate_opts(opts) @to_zulu = opts.fetch(:to_zulu, true) @timezone = opts.fetch(:timezone, UO_TZ) end |
Class Method Details
.validate_opts(opts) ⇒ Object
This is used to validate the options passed in to new() Will throw ArgumentError if things aren’t right.
27 28 29 30 31 32 |
# File 'lib/rmuh/rpt/log/parsers/unitedoperationsrpt.rb', line 27 def self.validate_opts(opts) fail ArgumentError, 'argument 1 should be a Hash' unless opts.class == Hash validate_bool_opt(opts, :to_zulu) validate_timezone(opts) end |
Instance Method Details
#parse(loglines) ⇒ Object
Parse the Array object which is the lines from the log. This expects arg 1 to be an Array object, otherwise it will throw an ArgumentError exception
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rmuh/rpt/log/parsers/unitedoperationsrpt.rb', line 53 def parse(loglines) unless loglines.is_a?(Array) fail ArgumentError, 'argument 1 must be an Array object' end loglines.map do |l| line = regex_match(l) zulu!(line, @timezone) if @to_zulu && line add_guid!(line) unless line.nil? line end.compact end |