Class: Snoopit::Detected
- Inherits:
-
Object
- Object
- Snoopit::Detected
- Defined in:
- lib/snoopit/detected.rb
Instance Attribute Summary collapse
-
#after ⇒ Object
readonly
Returns the value of attribute after.
-
#after_count ⇒ Object
readonly
Returns the value of attribute after_count.
-
#before ⇒ Object
readonly
Returns the value of attribute before.
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#finished ⇒ Object
readonly
Returns the value of attribute finished.
-
#line_no ⇒ Object
readonly
Returns the value of attribute line_no.
-
#match ⇒ Object
readonly
Returns the value of attribute match.
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
Instance Method Summary collapse
- #as_json(options = nil) ⇒ Object
- #finished? ⇒ Boolean
-
#initialize(comment, pre_before, after, match, file, line_no) ⇒ Detected
constructor
A new instance of Detected.
- #setup_before(pre_before) ⇒ Object
- #to_json(*a) ⇒ Object
- #track(line) ⇒ Object
Constructor Details
#initialize(comment, pre_before, after, match, file, line_no) ⇒ Detected
Returns a new instance of Detected.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/snoopit/detected.rb', line 6 def initialize(comment, pre_before, after, match, file, line_no) setup_before pre_before @comment = comment @after_count = 0 @after = Register.new(after) @match = match @file = file @line_no = line_no @finished = false end |
Instance Attribute Details
#after ⇒ Object (readonly)
Returns the value of attribute after.
4 5 6 |
# File 'lib/snoopit/detected.rb', line 4 def after @after end |
#after_count ⇒ Object (readonly)
Returns the value of attribute after_count.
4 5 6 |
# File 'lib/snoopit/detected.rb', line 4 def after_count @after_count end |
#before ⇒ Object (readonly)
Returns the value of attribute before.
4 5 6 |
# File 'lib/snoopit/detected.rb', line 4 def before @before end |
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
4 5 6 |
# File 'lib/snoopit/detected.rb', line 4 def comment @comment end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
4 5 6 |
# File 'lib/snoopit/detected.rb', line 4 def file @file end |
#finished ⇒ Object (readonly)
Returns the value of attribute finished.
4 5 6 |
# File 'lib/snoopit/detected.rb', line 4 def finished @finished end |
#line_no ⇒ Object (readonly)
Returns the value of attribute line_no.
4 5 6 |
# File 'lib/snoopit/detected.rb', line 4 def line_no @line_no end |
#match ⇒ Object (readonly)
Returns the value of attribute match.
4 5 6 |
# File 'lib/snoopit/detected.rb', line 4 def match @match end |
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
4 5 6 |
# File 'lib/snoopit/detected.rb', line 4 def regexp @regexp end |
Instance Method Details
#as_json(options = nil) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/snoopit/detected.rb', line 35 def as_json(=nil) { after: @after, match: @match, before: @before, file: @file, line_no: @line_no } end |
#finished? ⇒ Boolean
31 32 33 |
# File 'lib/snoopit/detected.rb', line 31 def finished? @finished end |
#setup_before(pre_before) ⇒ Object
17 18 19 |
# File 'lib/snoopit/detected.rb', line 17 def setup_before(pre_before) @before = Register.new pre_before.size, pre_before.register end |
#to_json(*a) ⇒ Object
45 46 47 |
# File 'lib/snoopit/detected.rb', line 45 def to_json(*a) as_json.to_json(*a) end |
#track(line) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/snoopit/detected.rb', line 21 def track(line) return if line == @match if @after_count < @after.size @after.push_front line @after_count += 1 else @finished = true end end |