Class: Leftovers::AST::SendNode

Inherits:
Node
  • Object
show all
Includes:
HasArguments
Defined in:
lib/leftovers/ast/send_node.rb

Instance Method Summary collapse

Methods included from HasArguments

#kwargs, #positional_arguments

Methods inherited from Node

#first, #hash?, #initialize, #kwargs, #parent, #parent=, #path, #positional_arguments, #privacy, #privacy=, #proc?, #scalar?, #second, #sym?, #to_literal_s, #to_scalar_value, #updated

Constructor Details

This class inherits a constructor from Leftovers::AST::Node

Instance Method Details

#argumentsObject



16
17
18
19
20
21
22
# File 'lib/leftovers/ast/send_node.rb', line 16

def arguments
  @memo[:arguments] ||= if block_pass_argument?
    children[2...-1]
  else
    children.drop(2)
  end
end

#as_arguments_listObject



24
25
26
# File 'lib/leftovers/ast/send_node.rb', line 24

def as_arguments_list
  first.as_arguments_list if name == :freeze
end

#block_given?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/leftovers/ast/send_node.rb', line 33

def block_given?
  block_pass_argument? || parent&.type == :block
end

#block_pass_argument?Boolean

Returns:

  • (Boolean)


28
29
30
31
# File 'lib/leftovers/ast/send_node.rb', line 28

def block_pass_argument?
  last_child = children.last
  last_child.respond_to?(:type) && last_child.type == :block_pass
end

#to_sObject



12
13
14
# File 'lib/leftovers/ast/send_node.rb', line 12

def to_s
  name.to_s
end