Class: Grepper::Match
- Inherits:
-
Object
- Object
- Grepper::Match
- Defined in:
- lib/grepper.rb
Overview
Grepper::Match represents a match on a single line, possibly with before- and/or after-context.
Match instances are created automatically by the Grepper object when you run it.
Instance Attribute Summary collapse
-
#after ⇒ Object
Returns the value of attribute after.
-
#before ⇒ Object
Returns the value of attribute before.
-
#line ⇒ Object
Returns the value of attribute line.
-
#lineno ⇒ Object
Returns the value of attribute lineno.
Instance Method Summary collapse
- #absolute_end ⇒ Object
- #absolute_start ⇒ Object
-
#initialize(line) ⇒ Match
constructor
A new instance of Match.
- #total_line_count ⇒ Object
Constructor Details
#initialize(line) ⇒ Match
190 191 192 193 |
# File 'lib/grepper.rb', line 190 def initialize(line) @before = @after = nil @line = line end |
Instance Attribute Details
#after ⇒ Object
Returns the value of attribute after.
189 190 191 |
# File 'lib/grepper.rb', line 189 def after @after end |
#before ⇒ Object
Returns the value of attribute before.
189 190 191 |
# File 'lib/grepper.rb', line 189 def before @before end |
#line ⇒ Object
Returns the value of attribute line.
189 190 191 |
# File 'lib/grepper.rb', line 189 def line @line end |
#lineno ⇒ Object
Returns the value of attribute lineno.
189 190 191 |
# File 'lib/grepper.rb', line 189 def lineno @lineno end |
Instance Method Details
#absolute_end ⇒ Object
205 206 207 |
# File 'lib/grepper.rb', line 205 def absolute_end lineno + after.to_s.scan(/\n/).size end |
#absolute_start ⇒ Object
201 202 203 |
# File 'lib/grepper.rb', line 201 def absolute_start lineno - before.to_s.scan(/\n/).size end |
#total_line_count ⇒ Object
195 196 197 198 199 |
# File 'lib/grepper.rb', line 195 def total_line_count before.to_s.scan(/\n/).size + after.to_s.scan(/\n/).size + 1 end |