Class: Spoom::Deadcode::Send
- Inherits:
-
Object
- Object
- Spoom::Deadcode::Send
- Defined in:
- lib/spoom/deadcode/send.rb
Overview
An abstraction to simplify handling of Prism::CallNode nodes.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
: Array.
-
#block ⇒ Object
readonly
: Prism::Node?.
-
#location ⇒ Object
readonly
: Location.
-
#name ⇒ Object
readonly
: String.
-
#node ⇒ Object
readonly
: Prism::CallNode.
-
#recv ⇒ Object
readonly
: Prism::Node?.
Instance Method Summary collapse
-
#each_arg(arg_type, &block) ⇒ Object
: [T] (Class arg_type) { (T arg) -> void } -> void.
-
#each_arg_assoc(&block) ⇒ Object
: { (Prism::Node key, Prism::Node? value) -> void } -> void.
-
#initialize(node:, name:, location:, recv: nil, args: [], block: nil) ⇒ Send
constructor
: ( | node: Prism::CallNode, | name: String, | location: Location, | ?recv: Prism::Node?, | ?args: Array, | ?block: Prism::Node? | ) -> void.
Constructor Details
#initialize(node:, name:, location:, recv: nil, args: [], block: nil) ⇒ Send
: ( | node: Prism::CallNode, | name: String, | location: Location, | ?recv: Prism::Node?, | ?args: Array, | ?block: Prism::Node? | ) -> void
34 35 36 37 38 39 40 41 |
# File 'lib/spoom/deadcode/send.rb', line 34 def initialize(node:, name:, location:, recv: nil, args: [], block: nil) @node = node @name = name @recv = recv @args = args @block = block @location = location end |
Instance Attribute Details
#args ⇒ Object (readonly)
: Array
18 19 20 |
# File 'lib/spoom/deadcode/send.rb', line 18 def args @args end |
#block ⇒ Object (readonly)
: Prism::Node?
21 22 23 |
# File 'lib/spoom/deadcode/send.rb', line 21 def block @block end |
#location ⇒ Object (readonly)
: Location
24 25 26 |
# File 'lib/spoom/deadcode/send.rb', line 24 def location @location end |
#name ⇒ Object (readonly)
: String
12 13 14 |
# File 'lib/spoom/deadcode/send.rb', line 12 def name @name end |
#node ⇒ Object (readonly)
: Prism::CallNode
9 10 11 |
# File 'lib/spoom/deadcode/send.rb', line 9 def node @node end |
#recv ⇒ Object (readonly)
: Prism::Node?
15 16 17 |
# File 'lib/spoom/deadcode/send.rb', line 15 def recv @recv end |
Instance Method Details
#each_arg(arg_type, &block) ⇒ Object
: [T] (Class arg_type) { (T arg) -> void } -> void
44 45 46 47 48 |
# File 'lib/spoom/deadcode/send.rb', line 44 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
: { (Prism::Node key, Prism::Node? value) -> void } -> void
51 52 53 54 55 56 57 58 59 |
# File 'lib/spoom/deadcode/send.rb', line 51 def each_arg_assoc(&block) args.each do |arg| next unless arg.is_a?(Prism::KeywordHashNode) || arg.is_a?(Prism::HashNode) arg.elements.each do |assoc| yield(assoc.key, assoc.value) if assoc.is_a?(Prism::AssocNode) end end end |