Sha256: 1cb801bcd9bad16a045d3edd6e1671bf06185a53b8ac5ea12ec925370acd03bc

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8

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

        # Perform regular dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          emit_receiver
          emit_attribute
          emit_operator
          visit_terminated(arguments.first)
        end

      private

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

        # Emit attribute
        #
        # @return [undefined]
        #
        # @api private
        #
        def emit_attribute
          write(attribute_name)
        end

        # Emit assignment operator
        #
        # @return [undefined]
        #
        # @api private
        #
        def emit_operator
          write(WS, T_ASN, WS)
        end

        # Return attribute name
        #
        # @return [String]
        #
        # @api private
        #
        def attribute_name
          string_selector[0..-2]
        end

      end # AttributeAssignment
    end # Send
  end # Emitter
end # Unparser

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
unparser-0.1.15 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.1.14 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.1.13 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.1.12 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.1.11 lib/unparser/emitter/send/attribute_assignment.rb
unparser-0.1.10 lib/unparser/emitter/send/attribute_assignment.rb