Sha256: 046205fd8b7c960ef2c961c6ca25390813801924e8e1ebf71683f7b392975632

Contents?: true

Size: 966 Bytes

Versions: 5

Compression:

Stored size: 966 Bytes

Contents

module Solve
  class Demand
    # A reference to the solver this demand belongs to
    #
    # @return [Solve::RubySolver,Solve::GecodeSolver]
    attr_reader :solver

    # The name of the artifact this demand is for
    #
    # @return [String]
    attr_reader :name

    # The acceptable constraint of the artifact this demand is for
    #
    # @return [Semverse::Constraint]
    attr_reader :constraint

    # @param [Solve::RubySolver,Solve::GecodeSolver] solver
    # @param [#to_s] name
    # @param [Semverse::Constraint, #to_s] constraint
    def initialize(solver, name, constraint = Semverse::DEFAULT_CONSTRAINT)
      @solver     = solver
      @name       = name
      @constraint = Semverse::Constraint.coerce(constraint)
    end

    def to_s
      "#{name} (#{constraint})"
    end

    def ==(other)
      other.is_a?(self.class) &&
        name == other.name &&
        constraint == other.constraint
    end
    alias_method :eql?, :==
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solve-4.0.4 lib/solve/demand.rb
solve-4.0.3 lib/solve/demand.rb
solve-4.0.2 lib/solve/demand.rb
solve-4.0.1 lib/solve/demand.rb
solve-4.0.0 lib/solve/demand.rb