class Unparser::Writer::Send
Writer
for send
Constants
- INDEX_ASSIGN
- INDEX_REFERENCE
- OPERATORS
Public Instance Methods
dispatch()
click to toggle source
# File lib/unparser/writer/send.rb, line 21 def dispatch effective_writer.dispatch end
emit_heredoc_reminders()
click to toggle source
# File lib/unparser/writer/send.rb, line 33 def emit_heredoc_reminders emitter(receiver).emit_heredoc_reminders if receiver arguments.each(&method(:emit_heredoc_reminder)) end
emit_mlhs()
click to toggle source
# File lib/unparser/writer/send.rb, line 25 def emit_mlhs effective_writer.emit_send_mlhs end
emit_selector()
click to toggle source
# File lib/unparser/writer/send.rb, line 29 def emit_selector write(details.string_selector) end
Private Instance Methods
arguments()
click to toggle source
# File lib/unparser/writer/send.rb, line 73 def arguments details.arguments end
avoid_clash?()
click to toggle source
# File lib/unparser/writer/send.rb, line 85 def avoid_clash? local_variable_clash? || parses_as_constant? end
details()
click to toggle source
# File lib/unparser/writer/send.rb, line 101 def details NodeDetails::Send.new(node) end
effective_writer()
click to toggle source
# File lib/unparser/writer/send.rb, line 40 def effective_writer writer_with(effective_writer_class, node) end
effective_writer_class()
click to toggle source
# File lib/unparser/writer/send.rb, line 45 def effective_writer_class if details.binary_syntax_allowed? Binary elsif details.selector_unary_operator? && n_send?(node) Unary elsif write_as_attribute_assignment? AttributeAssignment else Regular end end
emit_arguments()
click to toggle source
# File lib/unparser/writer/send.rb, line 65 def emit_arguments if arguments.empty? write('()') if receiver.nil? && avoid_clash? else emit_normal_arguments end end
emit_heredoc_reminder(argument)
click to toggle source
# File lib/unparser/writer/send.rb, line 81 def emit_heredoc_reminder(argument) emitter(argument).emit_heredoc_reminders end
emit_normal_arguments()
click to toggle source
# File lib/unparser/writer/send.rb, line 77 def emit_normal_arguments parentheses { delimited(arguments) } end
emit_operator()
click to toggle source
# File lib/unparser/writer/send.rb, line 61 def emit_operator write(OPERATORS.fetch(node.type)) end
emit_send_regular(node)
click to toggle source
# File lib/unparser/writer/send.rb, line 106 def emit_send_regular(node) if n_send?(node) writer_with(Regular, node).dispatch else visit(node) end end
local_variable_clash?()
click to toggle source
# File lib/unparser/writer/send.rb, line 89 def local_variable_clash? local_variable_scope.local_variable_defined_for_node?(node, selector) end
parses_as_constant?()
click to toggle source
# File lib/unparser/writer/send.rb, line 93 def parses_as_constant? test = Unparser.parse_either(selector.to_s).from_right do fail InvalidNodeError.new("Invalid selector for send node: #{selector.inspect}", node) end n_const?(test) end
write_as_attribute_assignment?()
click to toggle source
# File lib/unparser/writer/send.rb, line 57 def write_as_attribute_assignment? details.assignment_operator? end