class Constant < Definition
- Inherits from
Definition: #public?, #protected?, #private?, #multiline?, #text, #location, #inspect, #name, #full_path, #coverage_relevant?, #documented?, #qualified_name, #start_with?, #convert, #qualified_form, #container?, #alias?, #nested?, #documentation
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