Sha256: 21db0f08e28d18b031ff8191cf8b10b37de443da6cca9ecd8ce027a7388cdfca

Contents?: true

Size: 969 Bytes

Versions: 6

Compression:

Stored size: 969 Bytes

Contents

# encoding: utf-8

module Unparser
  class Emitter
    class Send
      # Emitter for arguments of send nodes
      class Arguments < Emitter

      private

        # Perform dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          return if children.empty?

          parentheses do
            delimited_plain(effective_arguments)
          end
        end

        # Return effective arguments
        #
        # @return [Parser::AST::Node]
        #
        # @api private
        #
        def effective_arguments
          last = children.length - 1
          children.each_with_index.map do |argument, index|
            if last.equal?(index) && argument.type.equal?(:hash) && argument.children.any?
              argument.updated(:hash_body)
            else
              argument
            end
          end
        end

      end # Arguments
    end # Send
  end # Emitter
end # Unparser

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
unparser-0.2.4 lib/unparser/emitter/send/arguments.rb
unparser-0.2.3 lib/unparser/emitter/send/arguments.rb
unparser-0.2.2 lib/unparser/emitter/send/arguments.rb
unparser-0.2.1 lib/unparser/emitter/send/arguments.rb
unparser-0.2.0 lib/unparser/emitter/send/arguments.rb
unparser-0.1.16 lib/unparser/emitter/send/arguments.rb