Module: ImproveYourCode::AST::SexpExtensions::MethodNodeBase

Included in:
DefNode, DefsNode
Defined in:
lib/improve_your_code/ast/sexp_extensions/methods.rb

Overview

Base module for utility methods for :def and :defs nodes.

Instance Method Summary collapse

Instance Method Details

#arg_namesObject



12
13
14
# File 'lib/improve_your_code/ast/sexp_extensions/methods.rb', line 12

def arg_names
  arguments.map(&:name)
end

#argumentsObject



8
9
10
# File 'lib/improve_your_code/ast/sexp_extensions/methods.rb', line 8

def arguments
  parameters.reject(&:block?)
end

#ends_with_bang?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/improve_your_code/ast/sexp_extensions/methods.rb', line 28

def ends_with_bang?
  name[-1] == '!'
end

#name_without_bangObject



24
25
26
# File 'lib/improve_your_code/ast/sexp_extensions/methods.rb', line 24

def name_without_bang
  name.to_s.chop
end

#parameter_namesObject



20
21
22
# File 'lib/improve_your_code/ast/sexp_extensions/methods.rb', line 20

def parameter_names
  parameters.map(&:name)
end

#parametersObject



16
17
18
# File 'lib/improve_your_code/ast/sexp_extensions/methods.rb', line 16

def parameters
  argslist.components
end