Sha256: 9e30cb47227719312dba4a182bfaa164be561a06cb25ba3c41a597638ec5f3bc

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Unparser
  class Emitter
    class Send
      # Emitter for send as attribute assignment
      class AttributeAssignment < self
        include Unterminated

        children :receiver, :selector, :first_argument

        # Perform regular dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          emit_receiver
          emit_attribute
          write(T_ASN)

          if arguments.one?
            visit(first_argument)
          else
            parentheses { delimited(arguments) }
          end
        end

      private

        # Emit receiver
        #
        # @return [Parser::AST::Node]
        #
        # @api private
        #
        def emit_receiver
          visit(receiver)
          write(T_DOT)
        end

        # Emit attribute
        #
        # @return [undefined]
        #
        # @api private
        #
        def emit_attribute
          write(non_assignment_selector)
        end
      end # AttributeAssignment
    end # Send
  end # Emitter
end # Unparser

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
unparser-0.4.9 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.4.8 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.4.7 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.4.6 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.4.5 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.4.4 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.4.3 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.4.2 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.4.1 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.4.0 lib/unparser/emitter/send/attribute_assignment.rb