Sha256: 240c643b1e24f334d200a9393c0283f51c402cc624abb367329b8e7967d7aad6

Contents?: true

Size: 817 Bytes

Versions: 2

Compression:

Stored size: 817 Bytes

Contents

module Solve
  class Solver
    # @author Andrew Garson <agarson@riotgames.com>
    # @author Jamie Winsor <reset@riotgames.com>
    class ConstraintTable
      attr_reader :rows

      def initialize
        @rows = Array.new
      end

      # @param [Solve::Dependency] dependency
      # @param [String, Symbol] source
      #
      # @return [Array<ConstraintRow>]
      def add(dependency, source)
        @rows << ConstraintRow.new(dependency, source)
      end

      def constraints_on_artifact(name)
        @rows.select do |row|
          row.name == name
        end.map { |row| row.constraint }
      end

      def remove_constraints_from_source!(source)
        from_source, others = @rows.partition { |row| row.source == source }
        @rows = others
        from_source
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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