Class: Diakonos::Finding
- Includes:
- RangeDelegator
- Defined in:
- lib/diakonos/finding.rb
Class Method Summary collapse
Instance Method Summary collapse
- #captured_group(index) ⇒ Object
-
#initialize(range, regexp_match) ⇒ Finding
constructor
A new instance of Finding.
Methods included from RangeDelegator
#contains?, #end_col, #end_row, #start_col, #start_row
Constructor Details
#initialize(range, regexp_match) ⇒ Finding
Returns a new instance of Finding.
30 31 32 33 |
# File 'lib/diakonos/finding.rb', line 30 def initialize(range, regexp_match) @range = range @regexp_match = regexp_match end |
Class Method Details
.confirm(range_, regexps, lines, search_area, regexp_match) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/diakonos/finding.rb', line 6 def self.confirm(range_, regexps, lines, search_area, regexp_match) matches = true range = range_.dup i = range.start_row + 1 regexps[1..-1].each do |re| if lines[i] !~ re matches = false break end range.end_row = i range.end_col = Regexp.last_match[0].length i += 1 end if ( matches && search_area.contains?( range.start_row, range.start_col ) && search_area.contains?( range.end_row, range.end_col - 1 ) ) Finding.new(range, regexp_match) end end |
Instance Method Details
#captured_group(index) ⇒ Object
35 36 37 |
# File 'lib/diakonos/finding.rb', line 35 def captured_group(index) @regexp_match[index] end |