Sha256: e75641bfb15ac7567504bc4e9da6e3c16e24aa29287152688b536198352f473e

Contents?: true

Size: 903 Bytes

Versions: 3

Compression:

Stored size: 903 Bytes

Contents

module AQL
  class Node
    class Literal
      # Singleton literal
      class Singleton < self
        include Concord.new(:token)

        handle(NilClass)
        handle(TrueClass)
        handle(FalseClass)

        private_class_method :new

        # Construct object
        #
        # @param [Object] object
        #
        # @return [Node::Literal::Singleton]
        #
        # @api private
        #
        def self.construct(object)
          MAPPING.fetch(object)
        end

      private

        # Emit node
        #
        # @return [undefined]
        #
        # @api private
        #
        def emit(buffer)
          buffer.append(token)
        end

        NULL  = new('null')
        FALSE = new('false')
        TRUE  = new('true')

        MAPPING = {
          nil   => NULL,
          false => FALSE,
          true  => TRUE
        }

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aql-0.0.3 lib/aql/node/literal/singleton.rb
aql-0.0.2 lib/aql/node/literal/singleton.rb
aql-0.0.1 lib/aql/node/literal/singleton.rb