Sha256: 24c1e9958c1dcdebf0bce897a0d62ec8095641fa5cf7826286d9c0dffd4c9e83
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
# encoding: utf-8 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
unparser-0.1.7 | lib/unparser/emitter/case.rb |
unparser-0.1.6 | lib/unparser/emitter/case.rb |