Module: ImproveYourCode::AST::SexpExtensions::BlockNode

Defined in:
lib/improve_your_code/ast/sexp_extensions/block.rb

Overview

Utility methods for :block nodes.

Instance Method Summary collapse

Instance Method Details

#argsObject



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

def args
  children[1]
end

#blockObject



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

def block
  children[2]
end

#callObject



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

def call
  children.first
end

#parameter_namesObject



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

def parameter_names
  parameters.children
end

#parametersObject



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

def parameters
  children[1] || []
end

#simple_nameObject



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

def simple_name
  :block
end

#without_block_arguments?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/improve_your_code/ast/sexp_extensions/block.rb', line 32

def without_block_arguments?
  args.components.empty?
end