Module: LogParser::Pattern

Included in:
RegExpPattern
Defined in:
lib/log_parser/pattern.rb

Overview

Represents a certain pattern log message. The model we use is that

* a pattern tells you if a message starts in a given line, and
* reads lines from there on until it ends.

The result will be a Message.

Instance Method Summary collapse

Instance Method Details

#begins_at?(_line) ⇒ true, false

This method is abstract.

Checks if this message pattern matches the given line.

Parameters:

  • _line (String)

    The log line currently under investigation.

Returns:

  • (true, false)

    ‘true` if (and only if) this pattern can parse a single message from the given line onwards.

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/log_parser/pattern.rb', line 16

def begins_at?(_line)
  raise NotImplementedError
end

#read(_lines) ⇒ Array<(Message, Int)>

This method is abstract.

Reads a message from the given lines.

Parameters:

Returns:

  • (Array<(Message, Int)>)

    An array of the message that was read, and the number of lines that it spans.

Raises:

  • If no message end could be found among the given lines.



29
30
31
# File 'lib/log_parser/pattern.rb', line 29

def read(_lines)
  raise NotImplementedError
end