Sha256: 013159fe5498a2cb28300ddf93fa46caa60ff460df116106a902ad2201c655e3

Contents?: true

Size: 611 Bytes

Versions: 24

Compression:

Stored size: 611 Bytes

Contents

# frozen_string_literal: true

module Unparser
  class Emitter
    # Emitter for array patterns
    class ArrayPattern < self

      handle :array_pattern
      handle :array_pattern_with_tail

    private

      def dispatch
        write('[')
        delimited(children, &method(:emit_member))
        write(', ') if node_type.equal?(:array_pattern_with_tail)
        write(']')
      end

      def emit_member(node)
        if n_match_rest?(node)
          writer_with(MatchRest, node).emit_array_pattern
        else
          visit(node)
        end
      end
    end # Pin
  end # Emitter
end # Unparser

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
unparser-0.5.3 lib/unparser/emitter/array_pattern.rb
unparser-0.5.2 lib/unparser/emitter/array_pattern.rb
unparser-0.5.1 lib/unparser/emitter/array_pattern.rb
unparser-0.5.0 lib/unparser/emitter/array_pattern.rb