Sha256: 82c6dd17709484616a56c0d45608b12a74f1c0085576884c102961cc57a70550
Contents?: true
Size: 1.59 KB
Versions: 2
Compression:
Stored size: 1.59 KB
Contents
# encoding: utf-8 module Unparser class Emitter # Emitter for case nodes class Case < self handle :case children :condition define_group :whens, 1..-2 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 whens.each(&method(:visit)) end # Emit condition # # @return [undefined] # # @api private # def emit_condition return unless condition write(WS) visit_terminated(condition) end end # Case # Emitter for when nodes class When < self handle :when define_group :captures, 0 .. -2 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(captures) end end # When end # Emitter end # Unparser
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
unparser-0.1.15 | lib/unparser/emitter/case.rb |
unparser-0.1.14 | lib/unparser/emitter/case.rb |