class RDoc::Constant
A constant
Attributes
Sets the module or class this is constant is an alias for.
The constant’s name
The constant’s value
The constant’s visibility
Public Class Methods
Source
# File lib/rdoc/code_object/constant.rb, line 32 def initialize(name, value, comment) super() @name = name @value = value @is_alias_for = nil @visibility = :public self.comment = comment end
Creates a new constant with name
, value
and comment
Calls superclass method
RDoc::CodeObject::new
Public Instance Methods
Source
# File lib/rdoc/code_object/constant.rb, line 47 def <=> other return unless self.class === other [parent_name, name] <=> [other.parent_name, other.name] end
Constants are ordered by name
Source
Source
# File lib/rdoc/code_object/constant.rb, line 66 def documented? return true if super return false unless @is_alias_for case @is_alias_for when String then found = @store.find_class_or_module @is_alias_for return false unless found @is_alias_for = found end @is_alias_for.documented? end
A constant is documented if it has a comment, or is an alias for a documented class or module.
Calls superclass method
RDoc::CodeObject#documented?
Source
# File lib/rdoc/code_object/constant.rb, line 81 def full_name @full_name ||= "#{parent_name}::#{@name}" end
Full constant name including namespace
Source
# File lib/rdoc/code_object/constant.rb, line 88 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
The module or class this constant is an alias for
Source
# File lib/rdoc/code_object/constant.rb, line 109 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
Dumps this Constant
for use by ri. See also marshal_load
Source
# File lib/rdoc/code_object/constant.rb, line 135 def marshal_load array initialize array[1], nil, array[5] @full_name = array[2] @visibility = array[3] || :public @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
Loads this Constant
from array
. For a loaded Constant
the following methods will return cached values:
Source
# File lib/rdoc/code_object/constant.rb, line 153 def path "#{@parent.path}##{@name}" end
Path to this constant for use with HTML generator output.
Source
# File lib/rdoc/code_object/constant.rb, line 171 def store= store super @file = @store.add_file @file.full_name if @file end
Sets the store for this class or module and its contained code objects.
Calls superclass method
RDoc::CodeObject#store=