Class: Unparser::NodeDetails::Send
Constant Summary
collapse
- ASSIGN_SUFFIX =
'='.freeze
- NON_ASSIGN_RANGE =
(0..-2).freeze
Constants included
from Constants
Constants::BINARY_OPERATORS, Constants::KEYWORDS, Constants::K_ALIAS, Constants::K_AND, Constants::K_BEGIN, Constants::K_BREAK, Constants::K_CASE, Constants::K_CLASS, Constants::K_DEF, Constants::K_DEFINE, Constants::K_DEFINED, Constants::K_DO, Constants::K_EEND, Constants::K_ELSE, Constants::K_ELSIF, Constants::K_ENCODING, Constants::K_END, Constants::K_ENSURE, Constants::K_FALSE, Constants::K_FILE, Constants::K_FOR, Constants::K_IF, Constants::K_IN, Constants::K_MODULE, Constants::K_NEXT, Constants::K_NIL, Constants::K_NOT, Constants::K_OR, Constants::K_POSTEXE, Constants::K_PREEXE, Constants::K_REDO, Constants::K_RESCUE, Constants::K_RETRY, Constants::K_RETURN, Constants::K_SELF, Constants::K_SUPER, Constants::K_THEN, Constants::K_TRUE, Constants::K_UNDEF, Constants::K_UNLESS, Constants::K_UNTIL, Constants::K_WHEN, Constants::K_WHILE, Constants::K_YIELD, Constants::UNARY_OPERATORS
Instance Method Summary
collapse
included
#n, #n?, #s, #unwrap_single_begin
Instance Method Details
#arguments ⇒ Object
54
55
56
|
# File 'lib/unparser/node_details/send.rb', line 54
def arguments
children[2..]
end
|
#arguments? ⇒ Boolean
37
38
39
|
# File 'lib/unparser/node_details/send.rb', line 37
def arguments?
arguments.any?
end
|
#assignment? ⇒ Boolean
49
50
51
|
# File 'lib/unparser/node_details/send.rb', line 49
def assignment?
string_selector[-1].eql?(ASSIGN_SUFFIX)
end
|
#assignment_operator? ⇒ Boolean
33
34
35
|
# File 'lib/unparser/node_details/send.rb', line 33
def assignment_operator?
assignment? && !selector_binary_operator? && !selector_unary_operator?
end
|
#binary_syntax_allowed? ⇒ Boolean
21
22
23
24
25
26
27
|
# File 'lib/unparser/node_details/send.rb', line 21
def binary_syntax_allowed?
selector_binary_operator? \
&& n_send?(node) \
&& arguments.one? \
&& !n_splat?(arguments.first) \
&& !n_kwargs?(arguments.first)
end
|
#non_assignment_selector ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/unparser/node_details/send.rb', line 41
def non_assignment_selector
if assignment?
string_selector[NON_ASSIGN_RANGE]
else
string_selector
end
end
|
#selector_binary_operator? ⇒ Boolean
17
18
19
|
# File 'lib/unparser/node_details/send.rb', line 17
def selector_binary_operator?
BINARY_OPERATORS.include?(selector)
end
|
#selector_unary_operator? ⇒ Boolean
29
30
31
|
# File 'lib/unparser/node_details/send.rb', line 29
def selector_unary_operator?
UNARY_OPERATORS.include?(selector)
end
|
#string_selector ⇒ Object
59
60
61
|
# File 'lib/unparser/node_details/send.rb', line 59
def string_selector
selector.to_s
end
|