On this page
End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class · Ruby 3.2
SyntaxSuggest::AroundBlockScan
This class is useful for exploring contents before and after a block
It searches above and below the passed in block to match for whatever criteria you give it:
Example:
def dog # 1
puts "bark" # 2
puts "bark" # 3
end # 4
scan = AroundBlockScan.new(
code_lines: code_lines
block: CodeBlock.new(lines: code_lines[1])
)
scan.scan_while { true }
puts scan.before_index # => 0
puts scan.after_index # => 3
Contents can also be filtered using AroundBlockScan#skip
To grab the next surrounding indentation use AroundBlockScan#scan_adjacent_indent