DecodeSourceDecodeSegment

class Segment

A chunk of code with an optional preceeding comment block.

# Get the first segment from a source file:
segment = source.segments.first

Definitions

def initialize(comments, language)

Initialize a new segment.

Signature

parameter comments Array(String)

The preceeding comments.

parameter language Language::Generic

The language of the code.

Implementation

def initialize(comments, language)
	@comments = comments
	@language = language
end

attr :comments

Signature

attribute Array(String)

The preceeding comments.

attr :language

Signature

attribute Language::Generic

The language of the code attached to this segment.

def documentation

An interface for accsssing the documentation of the definition.

Signature

returns Documentation | Nil

A class Decode::Documentation instance if this definition has comments.

Implementation

def documentation
	if @comments&.any?
		@documentation ||= Documentation.new(@comments, @language)
	end
end

def code

The source code trailing the comments.

Signature

returns String | Nil

Implementation

def code
end