lib/unparser/emitter/binary.rb in unparser-0.4.9 vs lib/unparser/emitter/binary.rb in unparser-0.5.0
- old
+ new
@@ -1,34 +1,21 @@
# frozen_string_literal: true
module Unparser
class Emitter
- # Base class for binary emitters
+ # Non send binary operator / keyword emitter
class Binary < self
- include Unterminated
+ handle :and, :or
- children :left, :right
-
- MAP = {
- or: T_OR,
- and: T_AND
- }.freeze
-
- handle(*MAP.keys)
-
private
- # Perform dispatch
- #
- # @return [undefined]
- #
- # @api private
- #
def dispatch
- visit(left)
- write(WS, MAP.fetch(node.type), WS)
- visit(right)
+ writer.dispatch
end
+ def writer
+ writer_with(Writer::Binary, node)
+ end
+ memoize :writer
end # Binary
end # Emitter
end # Unparser