Sha256: 8d21d6a8565e13042744f917317cf08782489c435b2a02618ab3a4d8064a080b
Contents?: true
Size: 1.53 KB
Versions: 16
Compression:
Stored size: 1.53 KB
Contents
module Unparser class Emitter # Emitter for case nodes class Case < self handle :case children :condition private # Perform dispatch # # @return [undefined] # # @api private # def dispatch write(K_CASE) emit_condition emit_whens emit_else k_end end # Emit else # # @return [undefined] # # @api private # def emit_else else_branch = children.last return unless else_branch write(K_ELSE) visit_indented(else_branch) end # Emit whens # # @return [undefined] # # @api private # def emit_whens nl children[1..-2].each do |child| visit(child) end end # Emit condition # # @return [undefined] # # @api private # def emit_condition return unless condition write(WS) visit(condition) end end # Case # Emitter for when nodes class When < self handle :when private # Perform dispatch # # @return [undefined] # # @api private # def dispatch write(K_WHEN, WS) emit_captures body = children.last emit_body(body) end # Emit captures # # @return [undefined] # # @api private # def emit_captures delimited(children[0..-2]) end end end # Emitter end # Unparser
Version data entries
16 entries across 16 versions & 1 rubygems