Sha256: 102e48935d3f71d71e113a6faaa3a5a3365949adb2d7ce002c69d7e406d142de

Contents?: true

Size: 882 Bytes

Versions: 24

Compression:

Stored size: 882 Bytes

Contents

# frozen_string_literal: true

module Unparser
  class Emitter
    # Arguments emitter
    class Args < self
      def emit_block_arguments
        delimited(normal_arguments)

        write(',') if normal_arguments.one? && n_arg?(normal_arguments.first)

        emit_shadowargs
      end

      def emit_def_arguments
        delimited(normal_arguments)
      end

      def emit_lambda_arguments
        delimited(normal_arguments)
        emit_shadowargs
      end

    private

      def emit_shadowargs
        return if shadowargs.empty?

        write('; ')
        delimited(shadowargs)
      end

      def normal_arguments
        children.reject(&method(:n_shadowarg?))
      end
      memoize :normal_arguments

      def shadowargs
        children.select(&method(:n_shadowarg?))
      end
      memoize :shadowargs

    end # Arguments
  end # Emitter
end # Unparser

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
unparser-0.6.15 lib/unparser/emitter/args.rb
unparser-0.6.14 lib/unparser/emitter/args.rb
unparser-0.6.13 lib/unparser/emitter/args.rb
unparser-0.6.12 lib/unparser/emitter/args.rb
unparser-0.6.10 lib/unparser/emitter/args.rb
unparser-0.6.9 lib/unparser/emitter/args.rb
unparser-0.6.8 lib/unparser/emitter/args.rb
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/unparser-0.6.7/lib/unparser/emitter/args.rb
unparser-0.6.7 lib/unparser/emitter/args.rb
unparser-0.6.6 lib/unparser/emitter/args.rb
unparser-0.6.5 lib/unparser/emitter/args.rb
unparser-0.6.4 lib/unparser/emitter/args.rb
unparser-0.6.3 lib/unparser/emitter/args.rb
unparser-0.6.2 lib/unparser/emitter/args.rb
unparser-0.6.1 lib/unparser/emitter/args.rb
unparser-0.6.0 lib/unparser/emitter/args.rb
unparser-0.5.7 lib/unparser/emitter/args.rb
unparser-0.5.6 lib/unparser/emitter/args.rb
unparser-0.5.5 lib/unparser/emitter/args.rb
unparser-0.5.4 lib/unparser/emitter/args.rb