Class: RDoc::AnyMethod
- Inherits:
-
CodeObject
- Object
- CodeObject
- RDoc::AnyMethod
- Includes:
- TokenStream
- Defined in:
- lib/rdoc/code_objects.rb
Overview
AnyMethod is the base class for objects representing methods
Instance Attribute Summary collapse
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
-
#block_params ⇒ Object
Returns the value of attribute block_params.
-
#call_seq ⇒ Object
Returns the value of attribute call_seq.
-
#dont_rename_initialize ⇒ Object
Returns the value of attribute dont_rename_initialize.
-
#is_alias_for ⇒ Object
list of other names for this method or a method we're aliasing.
-
#name ⇒ Object
Returns the value of attribute name.
-
#singleton ⇒ Object
Returns the value of attribute singleton.
-
#visibility ⇒ Object
Returns the value of attribute visibility.
Attributes inherited from CodeObject
#comment, #document_children, #document_self, #done_documenting, #force_documentation, #parent, #section, #viewer
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #add_alias(method) ⇒ Object
-
#initialize(text, name) ⇒ AnyMethod
constructor
A new instance of AnyMethod.
- #param_seq ⇒ Object
- #to_s ⇒ Object
Methods included from TokenStream
#add_token, #add_tokens, #pop_token, #start_collecting_tokens, #token_stream
Methods inherited from CodeObject
attr_overridable, #remove_classes_and_modules, #remove_methods_etc, #start_doc, #stop_doc
Constructor Details
#initialize(text, name) ⇒ AnyMethod
Returns a new instance of AnyMethod.
636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File 'lib/rdoc/code_objects.rb', line 636 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 |
Instance Attribute Details
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases
626 627 628 |
# File 'lib/rdoc/code_objects.rb', line 626 def aliases @aliases end |
#block_params ⇒ Object
Returns the value of attribute block_params
623 624 625 |
# File 'lib/rdoc/code_objects.rb', line 623 def block_params @block_params end |
#call_seq ⇒ Object
Returns the value of attribute call_seq
631 632 633 |
# File 'lib/rdoc/code_objects.rb', line 631 def call_seq @call_seq end |
#dont_rename_initialize ⇒ Object
Returns the value of attribute dont_rename_initialize
624 625 626 |
# File 'lib/rdoc/code_objects.rb', line 624 def dont_rename_initialize @dont_rename_initialize end |
#is_alias_for ⇒ Object
list of other names for this method or a method we're aliasing
627 628 629 |
# File 'lib/rdoc/code_objects.rb', line 627 def is_alias_for @is_alias_for end |
#name ⇒ Object
Returns the value of attribute name
621 622 623 |
# File 'lib/rdoc/code_objects.rb', line 621 def name @name end |
#singleton ⇒ Object
Returns the value of attribute singleton
625 626 627 |
# File 'lib/rdoc/code_objects.rb', line 625 def singleton @singleton end |
#visibility ⇒ Object
Returns the value of attribute visibility
622 623 624 |
# File 'lib/rdoc/code_objects.rb', line 622 def visibility @visibility end |
Instance Method Details
#<=>(other) ⇒ Object
650 651 652 |
# File 'lib/rdoc/code_objects.rb', line 650 def <=>(other) @name <=> other.name end |
#add_alias(method) ⇒ Object
682 683 684 |
# File 'lib/rdoc/code_objects.rb', line 682 def add_alias(method) @aliases << method end |
#param_seq ⇒ Object
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
# File 'lib/rdoc/code_objects.rb', line 660 def param_seq p = params.gsub(/\s*\#.*/, '') p = p.tr("\n", " ").squeeze(" ") p = "(" + p + ")" unless p[0] == ?( if (block = block_params) # If this method has explicit block parameters, remove any # explicit &block $stderr.puts p p.sub!(/,?\s*&\w+/) $stderr.puts p block.gsub!(/\s*\#.*/, '') block = block.tr("\n", " ").squeeze(" ") if block[0] == ?( block.sub!(/^\(/, '').sub!(/\)/, '') end p << " {|#{block}| ...}" end p end |
#to_s ⇒ Object
654 655 656 657 658 |
# File 'lib/rdoc/code_objects.rb', line 654 def to_s res = self.class.name + ": " + @name + " (" + @text + ")\n" res << @comment.to_s res end |