Sha256: 55b348a46e2815b9b52385128d74a6464b2a41b1557300baf992fe88b41f6b5b
Contents?: true
Size: 1.01 KB
Versions: 24
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module Unparser class Emitter # Emitter for case nodes class Case < self handle :case children :condition define_group :whens, 1..-2 private def dispatch write('case') emit_condition emit_whens emit_else k_end end def emit_else else_branch = children.last return unless else_branch write('else') emit_body(else_branch) end def emit_whens nl whens.each(&method(:visit)) end def emit_condition return unless condition ws visit(condition) end end # Case # Emitter for when nodes class When < self handle :when define_group :captures, 0..-2 private def dispatch write('when ') emit_captures emit_optional_body(children.last) end def emit_captures delimited(captures) end end # When end # Emitter end # Unparser
Version data entries
24 entries across 24 versions & 2 rubygems