Sha256: 9825fd0841cf438e1116db52bbc0a3d2f20405a60b3426a4a5be90673f366e1a

Contents?: true

Size: 758 Bytes

Versions: 5

Compression:

Stored size: 758 Bytes

Contents

# frozen_string_literal: true

module MiniKraken
  module Core
    class AnyValue
      attr_reader :rank

      # @param aName [String]
      # @param anEnv [Vocabulary]
      def initialize(aName, anEnv, alternate_names = [])
        @rank = anEnv.get_rank(aName, alternate_names)
      end

      def ==(other)
        if other.is_a?(AnyValue)
          rank == other.rank
        elsif other.id2name =~ /_\d+/
          rank == other.id2name.sub(/_/, '').to_i
        end
      end

      # Use same text representation as in Reasoned Schemer.
      def to_s
        "_#{rank}"
      end

      def ground?(_env)
        false
      end

      # @return [AnyValue]
      def quote(_env)
        self
      end
    end # class
  end # module
end # module

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mini_kraken-0.2.04 lib/mini_kraken/core/any_value.rb
mini_kraken-0.2.03 lib/mini_kraken/core/any_value.rb
mini_kraken-0.2.02 lib/mini_kraken/core/any_value.rb
mini_kraken-0.2.01 lib/mini_kraken/core/any_value.rb
mini_kraken-0.2.00 lib/mini_kraken/core/any_value.rb