DecodeSourceDecodeLanguageRubySegment

class Segment

A Ruby specific code segment.

Definitions

def initialize(comments, language, node, **options)

Initialize a new Ruby segment.

@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.

@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.

@returns [String | nil]

Implementation

def code
					@expression.slice
				end