Sha256: 0a807a7d45d47dc9b3c1a47cfd99a1c4d07131db976b96d350ccf9070a350597

Contents?: true

Size: 976 Bytes

Versions: 8

Compression:

Stored size: 976 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) &&
        self.name == other.name &&
        self.constraint == other.constraint
    end
    alias_method :eql?, :==
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
solve-3.1.1 lib/solve/demand.rb
solve-3.1.0 lib/solve/demand.rb
solve-3.0.1 lib/solve/demand.rb
solve-3.0.0 lib/solve/demand.rb
solve-2.0.3 lib/solve/demand.rb
solve-2.0.2 lib/solve/demand.rb
solve-2.0.1 lib/solve/demand.rb
solve-2.0.0 lib/solve/demand.rb