Sha256: be7d7586c5594f10b41e1e4597386ea3ee9aad2067a0c83ab222807b4eee0a55
Contents?: true
Size: 1004 Bytes
Versions: 18
Compression:
Stored size: 1004 Bytes
Contents
# frozen_string_literal: true module KepplerFrontend module Utils # CodeHandler class CodeSearch def initialize(html_lines) @html_lines = html_lines end def search_section(point_one, point_two) idx = [0, 0] idx = begin_index(point_one, idx) end_index(point_two, idx) end def search_line(point) idx = [0] idx = begin_index(point, idx) idx.first end private def begin_index(point_one, idx) @html_lines.each do |line| idx[0] = @html_lines.find_index(line) if line.include?(point_one) end idx end def end_index(point_two, idx) @html_lines[idx[0]..@html_lines.size].each do |line| next unless line.include?(point_two) html_lines = @html_lines[idx[0]..@html_lines.size] idx[1] = idx[0] + html_lines.find_index(line) break if (idx[1]).positive? end idx end end end end
Version data entries
18 entries across 18 versions & 1 rubygems