Class: Lugg::RequestMatcher
- Inherits:
-
Object
- Object
- Lugg::RequestMatcher
- Defined in:
- lib/lugg/request_matcher.rb
Overview
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....
Instance Method Summary collapse
-
#=~(line) ⇒ Object
rubocop:disable OpMethod.
- #active? ⇒ Boolean
- #finished? ⇒ Boolean
-
#initialize ⇒ RequestMatcher
constructor
A new instance of RequestMatcher.
Constructor Details
#initialize ⇒ RequestMatcher
Returns a new instance of RequestMatcher.
8 9 10 11 |
# File 'lib/lugg/request_matcher.rb', line 8 def initialize @active = false @finished = false end |
Instance Method Details
#=~(line) ⇒ Object
rubocop:disable OpMethod
21 22 23 24 25 26 27 28 29 30 |
# 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? ⇒ Boolean
13 14 15 |
# File 'lib/lugg/request_matcher.rb', line 13 def active? !!@active end |
#finished? ⇒ Boolean
17 18 19 |
# File 'lib/lugg/request_matcher.rb', line 17 def finished? !!@finished end |