Class: Prettyrb::Nodes::SendNode
- Inherits:
-
BaseNode
- Object
- Parser::AST::Node
- BaseNode
- Prettyrb::Nodes::SendNode
show all
- Defined in:
- lib/prettyrb/nodes/send_node.rb
Instance Method Summary
collapse
Methods inherited from BaseNode
#initialize, #parent, #string?
Instance Method Details
#arguments ⇒ Object
12
13
14
|
# File 'lib/prettyrb/nodes/send_node.rb', line 12
def arguments
children[2..-1]
end
|
#array_access? ⇒ Boolean
40
41
42
|
# File 'lib/prettyrb/nodes/send_node.rb', line 40
def array_access?
children[1] == :[]
end
|
#array_assignment? ⇒ Boolean
32
33
34
|
# File 'lib/prettyrb/nodes/send_node.rb', line 32
def array_assignment?
children[1] == :[]=
end
|
#called_on_heredoc? ⇒ Boolean
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/prettyrb/nodes/send_node.rb', line 44
def called_on_heredoc?
child = target
while child&.type == :send || child&.string?
return true if child.string? && child.heredoc?
child = child.children[0]
return false unless child.respond_to?(:type)
end
false
end
|
#heredoc_arguments? ⇒ Boolean
56
57
58
59
60
|
# File 'lib/prettyrb/nodes/send_node.rb', line 56
def heredoc_arguments?
arguments.any? do |child|
child.string? && child.heredoc? || (child.type == :send && child.called_on_heredoc?)
end
end
|
#infix? ⇒ Boolean
20
21
22
|
# File 'lib/prettyrb/nodes/send_node.rb', line 20
def infix?
!children[1].to_s.match?(/^[a-zA-Z_]/)
end
|
#left_hand_mass_assignment? ⇒ Boolean
36
37
38
|
# File 'lib/prettyrb/nodes/send_node.rb', line 36
def left_hand_mass_assignment?
parent&.type == :mlhs && method.to_s.end_with?("=")
end
|
#method ⇒ Object
8
9
10
|
# File 'lib/prettyrb/nodes/send_node.rb', line 8
def method
children[1]
end
|
#negate? ⇒ Boolean
28
29
30
|
# File 'lib/prettyrb/nodes/send_node.rb', line 28
def negate?
children[1] == :!
end
|
#negative? ⇒ Boolean
24
25
26
|
# File 'lib/prettyrb/nodes/send_node.rb', line 24
def negative?
children[1] == :-@ && children[2].nil?
end
|
#self_target? ⇒ Boolean
16
17
18
|
# File 'lib/prettyrb/nodes/send_node.rb', line 16
def self_target?
children[2].nil? && method.to_s.end_with?("@")
end
|
#target ⇒ Object
4
5
6
|
# File 'lib/prettyrb/nodes/send_node.rb', line 4
def target
children[0]
end
|