### Home Classes Methods

### In Files

- lib/rdoc/constant.rb

### Parent

RDoc::CodeObject

### Methods

- ::new
- #<=>
- #==
- #documented?
- #full_name
- #is_alias_for
- #marshal_dump
- #marshal_load
- #path
- #store=

### Files

- CONTRIBUTING.rdoc
- CVE-2013-0256.rdoc
- ExampleRDoc.rdoc
- LICENSE.rdoc
- Manifest.txt
- README.rdoc
- RI.rdoc
- Rakefile
- TODO.rdoc

### Class/Module Index

Quicksearch

- RDoc
- RDoc::Alias
- RDoc::AnonClass
- RDoc::AnyMethod
- RDoc::Attr
- RDoc::ClassModule
- RDoc::CodeObject
- RDoc::Comment
- RDoc::Constant
- RDoc::Context
- RDoc::Context::Section
- RDoc::CrossReference
- RDoc::ERBIO
- RDoc::ERBPartial
- RDoc::Encoding
- RDoc::Error
- RDoc::Extend
- RDoc::Gauntlet
- RDoc::Generator
- RDoc::Generator::Darkfish
- RDoc::Generator::JsonIndex
- RDoc::Generator::Markup
- RDoc::Generator::RI
- RDoc::GhostMethod
- RDoc::Include
- RDoc::Markdown
- RDoc::Markdown::Literals
- RDoc::Markup
- RDoc::Markup::AttrChanger
- RDoc::Markup::AttrSpan
- RDoc::Markup::AttributeManager
- RDoc::Markup::Attributes
- RDoc::Markup::BlankLine
- RDoc::Markup::BlockQuote
- RDoc::Markup::Document
- RDoc::Markup::Formatter
- RDoc::Markup::FormatterTestCase
- RDoc::Markup::HardBreak
- RDoc::Markup::Include
- RDoc::Markup::IndentedParagraph
- RDoc::Markup::List
- RDoc::Markup::ListItem
- RDoc::Markup::Paragraph
- RDoc::Markup::Parser
- RDoc::Markup::Parser::Error
- RDoc::Markup::Parser::ParseError
- RDoc::Markup::PreProcess
- RDoc::Markup::Raw
- RDoc::Markup::Rule
- RDoc::Markup::Special
- RDoc::Markup::TextFormatterTestCase
- RDoc::Markup::ToAnsi
- RDoc::Markup::ToBs
- RDoc::Markup::ToHtml
- RDoc::Markup::ToHtmlCrossref
- RDoc::Markup::ToHtmlSnippet
- RDoc::Markup::ToJoinedParagraph
- RDoc::Markup::ToLabel
- RDoc::Markup::ToMarkdown
- RDoc::Markup::ToRdoc
- RDoc::Markup::ToTableOfContents
- RDoc::Markup::ToTest
- RDoc::Markup::ToTtOnly
- RDoc::Markup::Verbatim
- RDoc::MetaMethod
- RDoc::MethodAttr
- RDoc::Mixin
- RDoc::NormalClass
- RDoc::NormalModule
- RDoc::Options
- RDoc::Parser
- RDoc::Parser::C
- RDoc::Parser::ChangeLog
- RDoc::Parser::Markdown
- RDoc::Parser::RD
- RDoc::Parser::Ruby
- RDoc::Parser::RubyTools
- RDoc::Parser::Simple
- RDoc::Parser::Text
- RDoc::RD
- RDoc::RD::BlockParser
- RDoc::RD::Inline
- RDoc::RD::InlineParser
- RDoc::RDoc
- RDoc::RI
- RDoc::RI::Driver
- RDoc::RI::Driver::Error
- RDoc::RI::Driver::NotFoundError
- RDoc::RI::Error
- RDoc::RI::Paths
- RDoc::Require
- RDoc::RubyLex
- RDoc::RubyLex::Error
- RDoc::RubyToken
- RDoc::RubygemsHook
- RDoc::Servlet
- RDoc::SingleClass
- RDoc::Stats
- RDoc::Stats::Normal
- RDoc::Stats::Quiet
- RDoc::Stats::Verbose
- RDoc::Store
- RDoc::Store::Error
- RDoc::Store::MissingFileError
- RDoc::Task
- RDoc::Task
- RDoc::TestCase
- RDoc::TokenStream
- RDoc::TomDoc
- RDoc::TopLevel
- Object

No matching classes.

# RDoc::Constant

A constant

### Attributes

is_alias_for[W]

Sets the module or class this is constant is an alias for.

name[RW]

The constant's name

value[RW]

The constant's value

visibility[RW]

The constant's visibility

### Public Class Methods

new(name, value, comment) click to toggle source

Creates a new constant with `name`, `value` and `comment`

    # File lib/rdoc/constant.rb, line 31
    def initialize(name, value, comment)
      super()

      @name  = name
      @value = value

      @is_alias_for = nil
      @visibility   = nil

      self.comment = comment
    end

### Public Instance Methods

<=>(other) click to toggle source

Constants are ordered by name

    # File lib/rdoc/constant.rb, line 46
    def <=> other
      return unless self.class === other

      [parent_name, name] <=> [other.parent_name, other.name]
    end

==(other) click to toggle source

Constants are equal when their parent and name is the same

    # File lib/rdoc/constant.rb, line 55
    def == other
      self.class == other.class and
        @parent == other.parent and
        @name == other.name
    end

documented?() click to toggle source

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 65
    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

full_name() click to toggle source

Full constant name including namespace

    # File lib/rdoc/constant.rb, line 80
    def full_name
      @full_name ||= "#{parent_name}::#{@name}"
    end

is_alias_for() click to toggle source

The module or class this constant is an alias for

    # File lib/rdoc/constant.rb, line 87
    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

marshal_dump() click to toggle source

Dumps this Constant for use by ri. See also marshal_load

    # File lib/rdoc/constant.rb, line 108
    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) click to toggle source

Loads this Constant from `array`. For a loaded Constant the following methods will return cached values:

- full_name

- parent_name

    # File lib/rdoc/constant.rb, line 134
    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

path() click to toggle source

Path to this constant for use with HTML generator output.

    # File lib/rdoc/constant.rb, line 152
    def path
      "#{@parent.path}##{@name}"
    end

store=(store) click to toggle source

Sets the store for this class or module and its contained code objects.

    # File lib/rdoc/constant.rb, line 170
    def store= store
      super

      @file = @store.add_file @file.full_name if @file
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.