Sha256: 93f0a44ceb8548713f1ebc0d1969105d593eef1a9eaf39218bc6d6605fde1bcc

Contents?: true

Size: 887 Bytes

Versions: 5

Compression:

Stored size: 887 Bytes

Contents

module Solve
  class Solver
    # @author Andrew Garson <andrew.garson@gmail.com>
    # @author Jamie Winsor <jamie@vialstudios.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

5 entries across 5 versions & 1 rubygems

Version Path
solve-0.4.2 lib/solve/solver/variable_row.rb
solve-0.4.1 lib/solve/solver/variable_row.rb
solve-0.4.0 lib/solve/solver/variable_row.rb
solve-0.4.0.rc1 lib/solve/solver/variable_row.rb
solve-0.3.1 lib/solve/solver/variable_row.rb