PHP 8.2.31
Preview: constant.rb Size: 3.34 KB
//proc/thread-self/root/opt/alt/ruby20/lib64/ruby/2.0.0/rdoc/constant.rb

##
# A constant

class RDoc::Constant < RDoc::CodeObject

  MARSHAL_VERSION = 0 # :nodoc:

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

  attr_writer :is_alias_for

  ##
  # The constant's name

  attr_accessor :name

  ##
  # The constant's value

  attr_accessor :value

  ##
  # The constant's visibility

  attr_accessor :visibility

  ##
  # Creates a new constant with +name+, +value+ and +comment+

  def initialize(name, value, comment)
    super()

    @name  = name
    @value = value

    @is_alias_for = nil
    @visibility   = nil

    self.comment = comment
  end

  ##
  # Constants are ordered by name

  def <=> other
    return unless self.class === other

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

  ##
  # Constants are equal when their #parent and #name is the same

  def == other
    self.class == other.class and
      @parent == other.parent and
      @name == other.name
  end

  ##
  # A constant is documented if it has a comment, or is an alias
  # for a documented class or module.

  def documented?
    super or is_alias_for && is_alias_for.documented?
  end

  ##
  # Full constant name including namespace

  def full_name
    @full_name ||= "#{parent_name}::#{@name}"
  end

  ##
  # The module or class this constant is an alias for

  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

  def inspect # :nodoc:
    "#<%s:0x%x %s::%s>" % [
      self.class, object_id,
      parent_name, @name,
    ]
  end

  ##
  # Dumps this Constant for use by ri.  See also #marshal_load

  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:
  #
  # * #full_name
  # * #parent_name

  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 to this constant for use with HTML generator output.

  def path
    "#{@parent.path}##{@name}"
  end

  def pretty_print q # :nodoc:
    q.group 2, "[#{self.class.name} #{full_name}", "]" do
      unless comment.empty? then
        q.breakable
        q.text "comment:"
        q.breakable
        q.pp @comment
      end
    end
  end

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

  def store= store
    super

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

  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

end

Directory Contents

Dirs: 8 × Files: 44

Name Size Perms Modified Actions
context DIR
- drwxr-xr-x 2024-03-03 22:43:41
Edit Download
generator DIR
- drwxr-xr-x 2024-03-03 22:43:41
Edit Download
markdown DIR
- drwxr-xr-x 2024-03-03 22:43:41
Edit Download
markup DIR
- drwxr-xr-x 2024-03-03 22:43:41
Edit Download
parser DIR
- drwxr-xr-x 2024-03-03 22:43:41
Edit Download
rd DIR
- drwxr-xr-x 2024-03-03 22:43:41
Edit Download
ri DIR
- drwxr-xr-x 2024-03-03 22:43:41
Edit Download
stats DIR
- drwxr-xr-x 2024-03-03 22:43:41
Edit Download
2.09 KB lrw-r--r-- 2012-11-27 04:28:14
Edit Download
142 B lrw-r--r-- 2012-11-27 04:28:14
Edit Download
5.90 KB lrw-r--r-- 2013-01-23 01:02:24
Edit Download
3.73 KB lrw-r--r-- 2013-01-23 01:02:24
Edit Download
19.15 KB lrw-r--r-- 2013-01-23 01:02:24
Edit Download
7.71 KB lrw-r--r-- 2013-01-23 01:02:24
Edit Download
121 B lrw-r--r-- 2012-11-27 04:28:14
Edit Download
5.39 KB lrw-r--r-- 2012-11-27 08:54:03
Edit Download
3.34 KB lrw-r--r-- 2012-11-27 08:54:03
Edit Download
28.26 KB lrw-r--r-- 2012-12-06 06:20:50
Edit Download
5.81 KB lrw-r--r-- 2013-01-04 06:16:13
Edit Download
2.74 KB lrw-r--r-- 2012-12-18 08:24:57
Edit Download
794 B lrw-r--r-- 2011-05-15 11:55:52
Edit Download
370 B lrw-r--r-- 2012-11-27 04:28:14
Edit Download
2.53 KB lrw-r--r-- 2012-11-27 04:28:14
Edit Download
1.72 KB lrw-r--r-- 2012-11-27 04:28:14
Edit Download
114 B lrw-r--r-- 2012-11-27 04:28:14
Edit Download
2.61 KB lrw-r--r-- 2012-11-27 04:28:14
Edit Download
2.58 KB lrw-r--r-- 2011-06-29 21:17:31
Edit Download
380.09 KB lrw-r--r-- 2012-12-01 03:58:39
Edit Download
28.31 KB lrw-r--r-- 2012-11-27 04:28:14
Edit Download
99 B lrw-r--r-- 2012-11-27 04:28:14
Edit Download
8.57 KB lrw-r--r-- 2012-11-27 04:28:14
Edit Download
2.06 KB lrw-r--r-- 2012-11-27 04:28:14
Edit Download
1.36 KB lrw-r--r-- 2012-11-27 04:28:14
Edit Download
28.49 KB lrw-r--r-- 2012-12-11 07:44:56
Edit Download
7.83 KB lrw-r--r-- 2013-01-04 06:16:13
Edit Download
3.54 KB lrw-r--r-- 2012-11-27 04:28:14
Edit Download
13.25 KB lrw-r--r-- 2012-12-13 07:58:47
Edit Download
935 B lrw-r--r-- 2012-11-27 04:28:14
Edit Download
315 B lrw-r--r-- 2012-11-27 04:28:14
Edit Download
4.91 KB lrw-r--r-- 2012-12-14 05:16:56
Edit Download
27.23 KB lrw-r--r-- 2012-12-18 07:31:36
Edit Download
11.21 KB lrw-r--r-- 2012-12-18 07:31:36
Edit Download
10.83 KB lrw-r--r-- 2013-02-05 08:24:20
Edit Download
330 B lrw-r--r-- 2012-11-27 04:28:14
Edit Download
9.78 KB lrw-r--r-- 2012-11-27 04:28:14
Edit Download
22.32 KB lrw-r--r-- 2013-01-25 00:15:08
Edit Download
7.66 KB lrw-r--r-- 2012-11-27 04:28:14
Edit Download
3.46 KB lrw-r--r-- 2012-11-29 23:34:29
Edit Download
7.59 KB lrw-r--r-- 2015-01-30 07:13:13
Edit Download
2.46 KB lrw-r--r-- 2012-11-27 04:28:14
Edit Download
5.70 KB lrw-r--r-- 2013-01-04 06:16:13
Edit Download
5.40 KB lrw-r--r-- 2013-01-23 01:02:24
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).