Sha256: f1fc5674fcdeebc63d5cc8127baf9c8c9f6f454d2cfb14ee1197c88f729236e5

Contents?: true

Size: 867 Bytes

Versions: 6

Compression:

Stored size: 867 Bytes

Contents

#
# Copyright (c) 2018-present, Blue Marble Payroll, LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#

module Logicality
  module Lexer
    class Token

      module Type
        VALUE       = :value
        AND_OP      = :and_op
        OR_OP       = :or_op
        NOT_OP      = :not_op
        LEFT_PAREN  = :left_paren
        RIGHT_PAREN = :right_paren
      end

      attr_reader :type, :value

      def initialize(type, value)
        raise ArgumentError, 'type is required'   unless type   && type.to_s.length > 0
        raise ArgumentError, 'value is required'  unless value  && value.to_s.length > 0

        @type   = Type.const_get(type.to_s.upcase.to_sym)
        @value  = value.to_s
      end

      def to_s
        "#{type}::#{value}"
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
logicality-1.0.4 lib/logicality/lexer/token.rb
logicality-1.0.3 lib/logicality/lexer/token.rb
logicality-1.0.2 lib/logicality/lexer/token.rb
logicality-1.0.1 lib/logicality/lexer/token.rb
logicality-1.0.0 lib/logicality/lexer/token.rb
logicality-0.0.1 lib/logicality/lexer/token.rb