Sha256: 0029fd654de97ac208faa85990fff1fd893c289464eeb459fb76641e35e3a63a

Contents?: true

Size: 1.22 KB

Versions: 17

Compression:

Stored size: 1.22 KB

Contents

module Unparser
  class Emitter
    class Literal

      # Emitter for hash keyvalue pair
      class HashPair < self
        HASHROCKET = ' => '.freeze

        handle :pair

      private

        # Perform dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          delimited(children, HASHROCKET)
        end

      end # HashPair

      # Base class for compound literal emitters
      class Compound < self

      private

        # Perform dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          util = self.class
          parentheses(util::OPEN, util::CLOSE) do
            delimited(children, util::DELIMITER)
          end
        end

        # Hash literal emitter
        class Hash < self
          OPEN      = '{'.freeze
          CLOSE     = '}'.freeze
          DELIMITER = ', '.freeze

          handle :hash
        end # Hash

        # Array literal emitter
        class Array < self
          OPEN      = '['.freeze
          CLOSE     = ']'.freeze
          DELIMITER = ', '.freeze

          handle :array
        end # Array

      end # Compound
    end # Literal
  end # Emitter
end # Unparser

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
unparser-0.1.5 lib/unparser/emitter/literal/composed.rb
unparser-0.1.4 lib/unparser/emitter/literal/composed.rb
unparser-0.1.3 lib/unparser/emitter/literal/composed.rb
unparser-0.1.2 lib/unparser/emitter/literal/composed.rb
unparser-0.1.1 lib/unparser/emitter/literal/composed.rb
unparser-0.1.0 lib/unparser/emitter/literal/composed.rb
unparser-0.0.18 lib/unparser/emitter/literal/composed.rb
unparser-0.0.16 lib/unparser/emitter/literal/composed.rb
unparser-0.0.15 lib/unparser/emitter/literal/composed.rb
unparser-0.0.14 lib/unparser/emitter/literal/composed.rb
unparser-0.0.13 lib/unparser/emitter/literal/composed.rb
unparser-0.0.12 lib/unparser/emitter/literal/composed.rb
unparser-0.0.11 lib/unparser/emitter/literal/composed.rb
unparser-0.0.10 lib/unparser/emitter/literal/composed.rb
unparser-0.0.8 lib/unparser/emitter/literal/composed.rb
unparser-0.0.7 lib/unparser/emitter/literal/composed.rb
unparser-0.0.6 lib/unparser/emitter/literal/composed.rb