Sha256: b3a09e9ca982fed16bf3cc4b0d759c006445a819de39a9024c0e0028b7126f5b

Contents?: true

Size: 928 Bytes

Versions: 6

Compression:

Stored size: 928 Bytes

Contents

module Solve
  class Demand
    # A reference to the solver this demand belongs to
    #
    # @return [Solve::Solver]
    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::Solver] 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

6 entries across 6 versions & 1 rubygems

Version Path
solve-1.2.1 lib/solve/demand.rb
solve-1.2.0 lib/solve/demand.rb
solve-1.1.0 lib/solve/demand.rb
solve-1.0.0.rc3 lib/solve/demand.rb
solve-1.0.0.rc2 lib/solve/demand.rb
solve-1.0.0.rc1 lib/solve/demand.rb