Class: Spoom::Deadcode::Send

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/spoom/deadcode/send.rb

Overview

An abstraction to simplify handling of SyntaxTree::CallNode, SyntaxTree::Command, SyntaxTree::CommandCall and SyntaxTree::VCall nodes.

Instance Method Summary collapse

Instance Method Details

#each_arg(arg_type, &block) ⇒ Object



22
23
24
25
26
# File 'lib/spoom/deadcode/send.rb', line 22

def each_arg(arg_type, &block)
  args.each do |arg|
    yield(T.unsafe(arg)) if arg.is_a?(arg_type)
  end
end

#each_arg_assoc(&block) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/spoom/deadcode/send.rb', line 29

def each_arg_assoc(&block)
  args.each do |arg|
    next unless arg.is_a?(SyntaxTree::BareAssocHash) || arg.is_a?(SyntaxTree::HashLiteral)

    arg.assocs.each do |assoc|
      yield(assoc.key, assoc.value) if assoc.is_a?(SyntaxTree::Assoc)
    end
  end
end