class Unparser::Emitter
Emitter
base class
Constants
- NO_INDENT
- REGISTRY
Registry for node emitters
Public Class Methods
emitter(buffer:, comments:, node:, local_variable_scope:)
click to toggle source
Return emitter
@return [Emitter]
@api private
rubocop:disable Metrics/ParameterLists
# File lib/unparser/emitter.rb, line 70 def self.emitter(buffer:, comments:, node:, local_variable_scope:) type = node.type klass = REGISTRY.fetch(type) do fail UnknownNodeError, "Unknown node type: #{type.inspect}" end klass.new( buffer: buffer, comments: comments, local_variable_scope: local_variable_scope, node: node ) end
Private Class Methods
handle(*types)
click to toggle source
Register emitter for type
@param [Symbol] types
@return [undefined]
@api private
# File lib/unparser/emitter.rb, line 50 def self.handle(*types) types.each do |type| fail "Handler for type: #{type} already registered" if REGISTRY.key?(type) REGISTRY[type] = self end end
Public Instance Methods
emit_mlhs()
click to toggle source
# File lib/unparser/emitter.rb, line 59 def emit_mlhs dispatch end
node_type()
click to toggle source
# File lib/unparser/emitter.rb, line 38 def node_type node.type end