A constant
Constants are ordered by name
# File rdoc/constant.rb, line 46
def <=> other
return unless self.class === other
[parent_name, name] <=> [other.parent_name, other.name]
end
A constant is documented if it has a comment, or is an alias for a documented class or module.
# File rdoc/constant.rb, line 65
def documented?
super or is_alias_for && is_alias_for.documented?
end
Full constant name including namespace
# File rdoc/constant.rb, line 72
def full_name
@full_name ||= "#{parent_name}::#{@name}"
end
The module or class this constant is an alias for
# File rdoc/constant.rb, line 79
def is_alias_for
case @is_alias_for
when String then
found = @store.find_class_or_module @is_alias_for
@is_alias_for = found if found
@is_alias_for
else
@is_alias_for
end
end
Dumps this Constant for use by ri. See also marshal_load
# File rdoc/constant.rb, line 100
def marshal_dump
alias_name = case found = is_alias_for
when RDoc::CodeObject then found.full_name
else found
end
[ MARSHAL_VERSION,
@name,
full_name,
@visibility,
alias_name,
parse(@comment),
@file.relative_name,
parent.name,
parent.class,
section.title,
]
end
Loads this Constant from array.
For a loaded Constant the following methods
will return cached values:
# File rdoc/constant.rb, line 126
def marshal_load array
initialize array[1], nil, array[5]
@full_name = array[2]
@visibility = array[3]
@is_alias_for = array[4]
# 5 handled above
# 6 handled below
@parent_name = array[7]
@parent_class = array[8]
@section_title = array[9]
@file = RDoc::TopLevel.new array[6]
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.