Sha256: 57d8219081ee04cb4bf9dd9ac08c73ea8a62bb23f19a3af8c8b09d040c689643

Contents?: true

Size: 883 Bytes

Versions: 2

Compression:

Stored size: 883 Bytes

Contents

module Solve
  class Solver
    # @author Andrew Garson <agarson@riotgames.com>
    # @author Jamie Winsor <reset@riotgames.com>
    class VariableRow
      attr_reader :artifact
      attr_reader :value
      attr_reader :sources

      # @param [String] artifact
      # @param [String, Symbol] source
      def initialize(artifact, source)
        @artifact = artifact
        @value = nil
        @sources = Array(source)
      end

      # @param [String, Symbol] source
      def add_source(source)
        @sources << source
      end

      def last_source
        @sources.last
      end

      def bind(value)
        @value = value
      end

      def unbind
        @value = nil
      end

      def bound?
        !@value.nil?
      end

      # @param [String, Symbol] source
      def remove_source(source)
        @sources.delete(source)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solve-0.4.4 lib/solve/solver/variable_row.rb
solve-0.4.3 lib/solve/solver/variable_row.rb