class Lugg::RequestMatcher

RequestMatcher is a flip-flop conditional, that becomes true when compared to one condition, and then stays true until a new condition. It is used to match log entries in a log file, starting to match when encountering a line with `Starting…` and stopping to match when encountering a line with `Completed…`.

Public Class Methods

new() click to toggle source
# File lib/lugg/request_matcher.rb, line 8
def initialize
  @active = false
  @finished = false
end

Public Instance Methods

=~(line) click to toggle source
# File lib/lugg/request_matcher.rb, line 21
def =~(line) # rubocop:disable OpMethod
  if line =~ /^Started/
    @active = true
  elsif line =~ /^Completed/
    @active = false
    @finished = true
  else
    @active
  end
end
active?() click to toggle source
# File lib/lugg/request_matcher.rb, line 13
def active?
  !!@active
end
finished?() click to toggle source
# File lib/lugg/request_matcher.rb, line 17
def finished?
  !!@finished
end