Class: Gitlab::StringRegexMarker
Instance Attribute Summary
#html_escaped, #raw_line, #rich_line
Instance Method Summary
collapse
#initialize
Instance Method Details
#mark(regex, group: 0, &block) ⇒ Object
5
6
7
8
9
|
# File 'lib/gitlab/string_regex_marker.rb', line 5
def mark(regex, group: 0, &block)
ranges = ranges(regex, group: group)
super(ranges, &block)
end
|
#mark_with_ranges(ranges, &block) ⇒ Object
11
12
13
|
# File 'lib/gitlab/string_regex_marker.rb', line 11
def mark_with_ranges(ranges, &block)
method(:mark).super_method.call(ranges, &block)
end
|
#ranges(regex, group: 0) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/gitlab/string_regex_marker.rb', line 15
def ranges(regex, group: 0)
ranges = []
offset = 0
while match = regex.match(raw_line[offset..])
begin_index = match.begin(group) + offset
end_index = match.end(group) + offset
ranges << (begin_index..(end_index - 1))
offset = end_index
end
ranges
end
|