Sha256: fb5a9c9211406de359b9c913098fd6dae965422c8fa6ff302d9395d2a323dd17

Contents?: true

Size: 1.58 KB

Versions: 2

Compression:

Stored size: 1.58 KB

Contents

module Unparser
  class Emitter
    class Send
      # Emitter for send to index references
      class Index < self

      private

        # Perform dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          emit_receiver
          emit_arguments
        end

        # Emit block within parentheses
        #
        # @return [undefined]
        #
        # @api private
        #
        def parentheses(&block)
          super(*INDEX_PARENS, &block)
        end

        # Emit receiver
        #
        # @return [undefined]
        #
        # @api private
        #
        def emit_receiver
          visit(first_child)
        end

        # Emitter for index reference nodes
        class Reference < self

        private

          # Emit arguments
          #
          # @return [undefined]
          #
          # @api private
          #
          def emit_arguments
            parentheses do
              delimited(arguments)
            end
          end
        end # Reference

        # Emitter for assign to index nodes
        class Assign < self

          # Emit arguments
          #
          # @return [undefined]
          #
          # @api private
          #
          def emit_arguments
            index, *assignment = arguments
            parentheses do
              delimited([index])
            end
            return if assignment.empty? # mlhs
            write(WS, O_ASN, WS)
            delimited(assignment)
          end

        end # Assign

      end # Index
    end # Send
  end # Emitter
end # Unparser

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
unparser-0.0.2 lib/unparser/emitter/send/index.rb
unparser-0.0.1 lib/unparser/emitter/send/index.rb