Skip to content
On this page
class · Ruby 4.0

SyntaxSuggest::CodeLine

< Object 13 instance methods 2 class methods

Represents a single line of code of a given source file

This object contains metadata about the line such as amount of indentation, if it is empty or not, and lexical data, such as if it has an end or a keyword in it.

Visibility of lines can be toggled off. Marking a line as invisible indicates that it should not be used for syntax checks. It’s functionally the same as commenting it out.

Example:

Example
line = CodeLine.from_source("def foo\n").first
line.number => 1
line.empty? # => false
line.visible? # => true
line.mark_invisible
line.visible? # => false

Class methods 2

Instance methods 13

Constants
No documentation available
Attributes
Read
No documentation available
Read
No documentation available

lex

Read
No documentation available
Read
No documentation available
No documentation available
Read
No documentation available
Read

When the code line is marked invisible we retain the original value of it’s line this is useful for debugging and for showing extra context

DisplayCodeWithLineNumbers will render all lines given to it, not just visible lines, it uses the original method to obtain them.