Class: RDoc::Constant
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
CodeObject
|
|
Instance Chain:
|
|
Inherits: |
RDoc::CodeObject
|
Defined in: | lib/rdoc/constant.rb |
Overview
A constant
Constant Summary
-
MARSHAL_VERSION =
Internal use only
# File 'lib/rdoc/constant.rb', line 70
Text
- Included
Class Method Summary
- .new(name, value, comment) ⇒ Constant constructor
CodeObject
- Inherited
.new | Creates a new |
Instance Attribute Summary
-
#documented? ⇒ Boolean
readonly
A constant is documented if it has a comment, or is an alias for a documented class or module.
-
#is_alias_for
rw
The module or class this constant is an alias for.
-
#is_alias_for=(value)
rw
Sets the module or class this is constant is an alias for.
-
#name
rw
The constant’s name.
-
#store=(store)
writeonly
Sets the store for this class or module and its contained code objects.
-
#value
rw
The constant’s value.
-
#visibility
rw
The constant’s visibility.
CodeObject
- Inherited
#comment | Our comment. |
#comment= | Replaces our comment with |
#display? | Should this |
#document_children | Do we document our children? |
#document_children= | Enables or disables documentation of this CodeObject’s children unless it has been turned off by :enddoc: |
#document_self | Do we document ourselves? |
#document_self= | Enables or disables documentation of this |
#documented? | Does this object have a comment with content or is |
#done_documenting | Are we done documenting (ie, did we come across a :enddoc:)? |
#done_documenting= | Turns documentation on/off, and turns on/off |
#file | Which file this code object was defined in. |
#force_documentation | Force documentation of this |
#force_documentation= | Force the documentation of this object unless documentation has been turned off by :enddoc: |
#full_name= | Sets the full_name overriding any computed full name. |
#ignored? | Has this class been ignored? |
#line | Line in |
#metadata | Hash of arbitrary metadata for this |
#parent | Our parent |
#parent= | Sets the parent |
#received_nodoc | Did we ever receive a |
#section | The section this |
#section= | Set the section this |
#store | The |
#store= | Sets the |
#suppressed? | Has this class been suppressed? |
#viewer | We are the model of the code, but we know that at some point we will be worked on by viewers. |
Instance Method Summary
-
#<=>(other)
Constants are ordered by name.
-
#==(other)
Constants are equal when their
#parent
and #name is the same. -
#full_name
Full constant name including namespace.
-
#marshal_dump
Dumps this
Constant
for use by ri. -
#marshal_load(array)
Loads this
Constant
fromarray
. -
#path
Path to this constant for use with HTML generator output.
- #inspect Internal use only
- #pretty_print(q) Internal use only
- #to_s Internal use only
CodeObject
- Inherited
#each_parent | Yields each parent of this |
#file_name | File name where this |
#ignore | Use this to ignore a |
#options | The options instance from the store this |
#parent_file_name | File name of our parent. |
#parent_name | Name of our parent. |
#record_location | Records the |
#start_doc | Enable capture of documentation unless documentation has been turned off by :enddoc: |
#stop_doc | Disable capture of documentation. |
#suppress | Use this to suppress a |
#initialize_visibility | Initializes state for visibility of this |
Generator::Markup
- Included
#aref_to | Generates a relative URL from this object’s path to |
#as_href | Generates a relative URL from |
#cvs_url | Build a webcvs URL starting for the given |
#description | Handy wrapper for marking up this object’s comment. |
#formatter | Creates an |
Text
- Included
#expand_tabs | Expands tab characters in |
#flush_left | Flush |
#markup | Convert a string in markup format into HTML. |
#normalize_comment | Strips hashes, expands tabs then flushes |
#parse | Normalizes |
#snippet | The first |
#strip_hashes | Strips leading # characters from |
#strip_newlines | Strips leading and trailing n characters from |
#strip_stars | Strips /* */ style comments. |
#to_html | Converts ampersand, dashes, ellipsis, quotes, copyright and registered trademark symbols in |
#wrap | Wraps |
Constructor Details
.new(name, value, comment) ⇒ Constant
[ GitHub ]
Instance Attribute Details
#documented? ⇒ Boolean
(readonly)
A constant is documented if it has a comment, or is an alias for a documented class or module.
# File 'lib/rdoc/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
#is_alias_for (rw)
The module or class this constant is an alias for
# File 'lib/rdoc/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
#is_alias_for=(value) (rw)
Sets the module or class this is constant is an alias for.
# File 'lib/rdoc/constant.rb', line 12
attr_writer :is_alias_for
#name (rw)
The constant’s name
# File 'lib/rdoc/constant.rb', line 17
attr_accessor :name
#store=(store) (writeonly)
Sets the store for this class or module and its contained code objects.
# File 'lib/rdoc/constant.rb', line 171
def store= store super @file = @store.add_file @file.full_name if @file end
#value (rw)
The constant’s value
# File 'lib/rdoc/constant.rb', line 22
attr_accessor :value
#visibility (rw)
The constant’s visibility
# File 'lib/rdoc/constant.rb', line 27
attr_accessor :visibility
Instance Method Details
#<=>(other)
Constants are ordered by name
#==(other)
Constants are equal when their #parent
and #name is the same
# File 'lib/rdoc/constant.rb', line 56
def == other self.class == other.class and @parent == other.parent and @name == other.name end
#full_name
Full constant name including namespace
# File 'lib/rdoc/constant.rb', line 81
def full_name @full_name ||= "#{parent_name}::#{@name}" end
#inspect
# File 'lib/rdoc/constant.rb', line 99
def inspect # :nodoc: "#<%s:0x%x %s::%s>" % [ self.class, object_id, parent_name, @name, ] end
#marshal_dump
Dumps this Constant
for use by ri. See also #marshal_load
# File 'lib/rdoc/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
#marshal_load(array)
Loads this Constant
from array
. For a loaded Constant
the following methods will return cached values:
-
#parent_name
# File 'lib/rdoc/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
#path
Path to this constant for use with HTML generator output.
# File 'lib/rdoc/constant.rb', line 153
def path "#{@parent.path}##{@name}" end
#pretty_print(q)
#to_s
# File 'lib/rdoc/constant.rb', line 177
def to_s # :nodoc: parent_name = parent ? parent.full_name : '(unknown)' if is_alias_for "constant #{parent_name}::#@name -> #{is_alias_for}" else "constant #{parent_name}::#@name" end end