In Files

  • rdoc/code_objects.rb

Files

Class/Module Index [+]

Quicksearch

RDoc::AnyMethod

AnyMethod is the base class for objects representing methods

Attributes

aliases[R]

list of other names for this method

block_params[RW]
call_seq[RW]
dont_rename_initialize[RW]
is_alias_for[RW]

method we’re aliasing

name[RW]
singleton[RW]
text[R]
visibility[RW]

Public Class Methods

new(text, name) click to toggle source
 
               # File rdoc/code_objects.rb, line 856
def initialize(text, name)
  super()
  @text = text
  @name = name
  @token_stream  = nil
  @visibility    = :public
  @dont_rename_initialize = false
  @block_params  = nil
  @aliases       = []
  @is_alias_for  = nil
  @comment = ""
  @call_seq = nil
end
            

Public Instance Methods

<=>(other) click to toggle source
 
               # File rdoc/code_objects.rb, line 870
def <=>(other)
  @name <=> other.name
end
            
add_alias(method) click to toggle source
 
               # File rdoc/code_objects.rb, line 874
def add_alias(method)
  @aliases << method
end
            
inspect() click to toggle source
 
               # File rdoc/code_objects.rb, line 878
def inspect
  alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil
  "#<%s:0x%x %s%s%s (%s)%s>" % [
    self.class, object_id,
    parent_name,
    singleton ? '::' : '#',
    name,
    visibility,
    alias_for,
  ]
end
            
param_seq() click to toggle source
 
               # File rdoc/code_objects.rb, line 890
def param_seq
  params = params.gsub(/\s*\#.*/, '')
  params = params.tr("\n", " ").squeeze(" ")
  params = "(#{params})" unless p[0] == ?(

  if block = block_params then # yes, =
    # If this method has explicit block parameters, remove any explicit
    # &block
    params.sub!(/,?\s*&\w+/)

    block.gsub!(/\s*\#.*/, '')
    block = block.tr("\n", " ").squeeze(" ")
    if block[0] == ?(
      block.sub!(/^\(/, '').sub!(/\)/, '')
    end
    params << " { |#{block}| ... }"
  end

  params
end
            
to_s() click to toggle source
 
               # File rdoc/code_objects.rb, line 911
def to_s
  res = self.class.name + ": " + @name + " (" + @text + ")\n"
  res << @comment.to_s
  res
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus