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

Inherits:
AstNode
  • Object
show all
Defined in:
lib/yard/parser/ruby/ast_node.rb

Managing node state collapse

Constructor Details

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

Instance Method Details

#def?Boolean

Returns:

  • (Boolean)


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

def def?; true end

#kw?Boolean

Returns:

  • (Boolean)


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

def kw?; true end

#method_name(name_only = false) ⇒ Object



485
486
487
488
# File 'lib/yard/parser/ruby/ast_node.rb', line 485

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

#namespaceObject



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

def namespace; first if index_adjust > 0 end

#parameters(include_block_param = true) ⇒ Object



490
491
492
493
494
# File 'lib/yard/parser/ruby/ast_node.rb', line 490

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

#signatureObject



496
497
498
499
500
501
502
503
504
505
# File 'lib/yard/parser/ruby/ast_node.rb', line 496

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