Class: RDoc::Alias (Ruby 2.7.2)
Description: Class : RDoc::Alias - Ruby 2.7.2

### Home Classes Methods

### In Files

- rdoc/alias.rb

### Parent

RDoc::CodeObject

### Methods

- ::new
- #<=>
- #aref
- #full_old_name
- #html_name
- #name_prefix
- #pretty_name
- #pretty_new_name
- #pretty_old_name

### Class/Module Index

Quicksearch

- InnerStateLex
- Object
- 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::Generator
- RDoc::Generator::Darkfish
- RDoc::Generator::JsonIndex
- RDoc::Generator::Markup
- RDoc::Generator::POT
- RDoc::Generator::POT::MessageExtractor
- RDoc::Generator::POT::PO
- RDoc::Generator::POT::POEntry
- RDoc::Generator::RI
- RDoc::GhostMethod
- RDoc::I18n
- RDoc::I18n::Locale
- RDoc::I18n::Text
- 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::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::MyStringScanner
- RDoc::Markup::Parser::ParseError
- RDoc::Markup::PreProcess
- RDoc::Markup::Raw
- RDoc::Markup::RegexpHandling
- RDoc::Markup::Rule
- 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::RipperStateLex
- RDoc::Parser::RipperStateLex::InnerStateLex
- 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::RI::Task
- RDoc::Require
- 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::Text
- RDoc::TokenStream
- RDoc::TomDoc
- RDoc::TopLevel
- RDocTask

No matching classes.

# RDoc::Alias

frozen_string_literal: true

Represent an alias, which is an old_name/new_name pair associated with a particular context

### Attributes

name[R]

Aliased method’s name

new_name[R]

Aliased method’s name

old_name[R]

Aliasee method’s name

singleton[RW]

Is this an alias declared in a singleton context?

text[R]

Source file token stream

### Public Class Methods

new(text, old_name, new_name, comment, singleton = false) click to toggle source

Creates a new Alias with a token stream of `text` that aliases `old_name` to `new_name`, has `comment` and is a `singleton` context.

                   # File rdoc/alias.rb, line 37
    def initialize(text, old_name, new_name, comment, singleton = false)
      super()

      @text = text
      @singleton = singleton
      @old_name = old_name
      @new_name = new_name
      self.comment = comment
    end

### Public Instance Methods

<=>(other) click to toggle source

Order by singleton then new_name

                   # File rdoc/alias.rb, line 50
    def <=>(other)
      [@singleton ? 0 : 1, new_name] <=> [other.singleton ? 0 : 1, other.new_name]
    end

aref() click to toggle source

HTML fragment reference for this alias

                   # File rdoc/alias.rb, line 57
    def aref
      type = singleton ? 'c' : 'i'
      "#alias-#{type}-#{html_name}"
    end

full_old_name() click to toggle source

Full old name including namespace

                   # File rdoc/alias.rb, line 65
    def full_old_name
      @full_name || "#{parent.name}#{pretty_old_name}"
    end

html_name() click to toggle source

HTML id-friendly version of `#new_name`.

                   # File rdoc/alias.rb, line 72
    def html_name
      CGI.escape(@new_name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
    end

name_prefix() click to toggle source

‘::’ for the alias of a singleton method/attribute, ‘#’ for instance-level.

                   # File rdoc/alias.rb, line 87
    def name_prefix
      singleton ? '::' : '#'
    end

pretty_name() click to toggle source
Alias for: pretty_new_name
pretty_new_name() click to toggle source

New name with prefix ‘::’ or ‘#’.

                   # File rdoc/alias.rb, line 101
    def pretty_new_name
      "#{singleton ? '::' : '#'}#{@new_name}"
    end

Also aliased as: pretty_name
pretty_old_name() click to toggle source

Old name with prefix ‘::’ or ‘#’.

                   # File rdoc/alias.rb, line 94
    def pretty_old_name
      "#{singleton ? '::' : '#'}#{@old_name}"
    end