123456789_123456789_123456789_123456789_123456789_

Class: YARD::Parser::Ruby::MethodDefinitionNode

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, AstNode, ::Array
Instance Chain:
self, AstNode, ::Array
Inherits: YARD::Parser::Ruby::AstNode
Defined in: lib/yard/parser/ruby/ast_node.rb

Constant Summary

AstNode - Inherited

KEYWORDS

Managing node state

Class Method Summary

AstNode - Inherited

.new

Creates a new AST node.

.node_class_for

Finds the node subclass that should be instantiated for a specific node type.

Instance Attribute Summary

Instance Method Summary

AstNode - Inherited

#==, #children, #first_line, #inspect,
#jump

Searches through the node and all descendants and returns the first node with a type matching any of node_types, otherwise returns the original node (self).

#line, #pretty_print, #show,
#traverse

Traverses the object and yields each node (including descendants) in order.

#unfreeze

Resets node state in tree.

#reset_line_info

Resets line information.

::Array - Inherited

#place

Places values before or after another object (by value) in an array.

Constructor Details

This class inherits a constructor from YARD::Parser::Ruby::AstNode

Instance Attribute Details

#def?Boolean (readonly)

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 481

def def?; true end

#kw?Boolean (readonly)

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 480

def kw?; true end

Instance Method Details

#block

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 506

alias block last

#index_adjust (private)

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 510

def index_adjust
  type == :defs ? 2 : 0
end

#method_name(name_only = false)

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 484

def method_name(name_only = false)
  name = self[index_adjust]
  name_only ? name.jump(:ident).first.to_sym : name
end

#namespace

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 482

def namespace; first if index_adjust > 0 end

#parameters(include_block_param = true)

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 489

def parameters(include_block_param = true)
  return unless params = self[1 + index_adjust]
  params = params[0] if params.type == :paren
  include_block_param ? params : params[0...-1]
end

#signature

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 495

def signature
  params_src = ''
  params = self[1 + index_adjust]
  if params and params.first
    params_src = params.type == :paren ? '' : ' '
    params_src += params.source.gsub(/\s+(\s|\))/m, '\1')
  end

  "def #{method_name(true)}#{params_src}"
end