Sha256: 51d2a8d9b2bdd9e88468a012c6d4749ea3b9f3cda885fe17df68595ef227dcd1
Contents?: true
Size: 1.86 KB
Versions: 7
Compression:
Stored size: 1.86 KB
Contents
# encoding: utf-8 module Unparser class Emitter class Literal # Base class for dynamic literal emitters class Dynamic < self private # Perform dispatch # # @return [undefined] # # @api private # def dispatch util = self.class if interpolation? visit_parentheses(dynamic_body, util::OPEN, util::CLOSE) else emit_non_interpolated end end # Test for interpolation # # @return [true] # if dynamic component was interpolated # # @return [false] # otherwise # # @api private # def interpolation? children.any? { |child| child.type != :str } end # Return dynamic body # # @return [Parser::AST::Node] # # @api private # def dynamic_body Parser::AST::Node.new(:dyn_str_body, children) end # Dynamic string literal emitter class String < self OPEN = CLOSE = '"'.freeze handle :dstr private # Emit non interpolated form # # @return [undefined] # # @api private # def emit_non_interpolated delimited(children, WS) end end # String # Dynamic symbol literal emitter class Symbol < self OPEN = ':"'.freeze CLOSE = '"'.freeze handle :dsym private # Emit non interpolated form # # @return [undefined] # # @api private # def emit_non_interpolated visit_parentheses(dynamic_body, OPEN, CLOSE) end end # Symbol end end # Literal end # Emitter end # Unparser
Version data entries
7 entries across 7 versions & 1 rubygems