class Segment
A Ruby specific code segment.
Definitions
def initialize(comments, language, node, **options)
Initialize a new Ruby segment.
Signature
-
parameter
comments
Array(String)
The comments for this segment.
-
parameter
language
Language
The language instance.
-
parameter
node
Prism::Node
The syntax tree node.
-
parameter
options
Hash
Additional options.
Implementation
def initialize(comments, language, node, **options)
super(comments, language, **options)
@node = node
@expression = node.location
end
attr :node
The parser syntax tree node.
def expand(node)
Expand the segment to include another node.
Signature
-
parameter
node
Prism::Node
The node to include.
Implementation
def expand(node)
@expression = @expression.join(node.location)
end
def code
The source code trailing the comments.
Signature
-
returns
String | nil
Implementation
def code
@expression.slice
end