DecodeSourceDecodeLanguageRubyConstant

class Constant

A Ruby-specific constant.

Definitions

def short_form

The short form of the constant. e.g. NAME.

Implementation

def short_form
	@node.name.to_s
end

def nested_name

Generate a nested name for the constant.

Implementation

def nested_name
	"::#{@name}"
end

def long_form

The long form of the constant. e.g. NAME = "Alice".

Implementation

def long_form
	if @node.location.start_line == @node.location.end_line
		@node.location.slice
	elsif @node.value&.type == :array_node
		"#{@node.name} = [...]"
	elsif @node.value&.type == :hash_node
		"#{@node.name} = {...}"
	else
		self.short_form
	end
end