Sha256: 967768b5e8ef4d04eae3e6da510b699458d3d301e1b664a60b6591f45f9a5599

Contents?: true

Size: 1.6 KB

Versions: 3

Compression:

Stored size: 1.6 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_terminated(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, T_ASN, WS)
            delimited(assignment)
          end

        end # Assign

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
unparser-0.1.2 lib/unparser/emitter/send/index.rb
unparser-0.1.1 lib/unparser/emitter/send/index.rb
unparser-0.1.0 lib/unparser/emitter/send/index.rb