class Segment
A Ruby specific code segment.
Definitions
def initialize(comments, language, node, **options)
Initialize a new Ruby segment.
Signature
-
parameter
commentsArray(String) The comments for this segment.
-
parameter
languageGeneric The language instance.
-
parameter
nodePrism::Node The syntax tree node.
-
parameter
optionsHash 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
nodePrism::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?
Implementation
def code
@expression.slice
end