Sha256: 5cb6a3aa9dd2f9f4b7c088dcc93fef099b326365c1ec9de4287935647fca7c3f

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

require_relative 'association'

module MiniKraken
  module Core
    # A specialized association that bind a variable to a value from another
    # association.
    class AssociationCopy < Association
      # @return [String] internal name of variable being associated the value.
      attr_accessor :i_name

      # @return [Association] the association from which the value is shared.
      attr_reader :source

      # @param aVariable [Variable, String] A variable or its internal name.
      # @param anAssoc [Association] an association that shares its value.
      def initialize(aVariable, anAssoc)
        super(aVariable, nil)
        @source = anAssoc
      end

      # Is the associated value floating, that is, it does contain
      # a variable that is either unbound or floating?
      # @param ctx [Core::Context]
      # @return [Boolean]
      def floating?(ctx)
        source.floating?(ctx)
      end

      # Is the associated value pinned, that is, doesn't contain
      # an unbound or floating variable?
      # @param ctx [Core::Context]
      # @return [Boolean]
      def pinned?(ctx)
        source.pinned?(ctx)
      end

      # @return [Term] the MiniKraken value associated with the variable
      def value
        source.value
      end

      # @return [Array<String>] The i_names of direct dependent variables
      def dependencies(ctx)
         source.dependencies(ctx)
      end
    end # class
  end # module
end # module

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mini_kraken-0.3.03 lib/mini_kraken/core/association_copy.rb
mini_kraken-0.3.02 lib/mini_kraken/core/association_copy.rb
mini_kraken-0.3.01 lib/mini_kraken/core/association_copy.rb
mini_kraken-0.3.00 lib/mini_kraken/core/association_copy.rb