Sha256: 29bbea2070d556f0a26f59b0694505b1547f7e7d96fcc6f1c6fd83698aff690c
Contents?: true
Size: 1.23 KB
Versions: 5
Compression:
Stored size: 1.23 KB
Contents
module Solve # @author Jamie Winsor <jamie@vialstudios.com> 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 [Solve::Constraint] attr_reader :constraint # @param [Solve::Solver] solver # @param [#to_s] name # @param [Solve::Constraint, #to_s] constraint def initialize(solver, name, constraint = ">= 0.0.0") @solver = solver @name = name @constraint = if constraint.is_a?(Solve::Constraint) constraint else Constraint.new(constraint.to_s) end end # Remove this demand from the solver it belongs to # # @return [Solve::Demand, nil] def delete unless solver.nil? result = solver.remove_demand(self) @solver = nil result end 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
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
solve-0.4.2 | lib/solve/demand.rb |
solve-0.4.1 | lib/solve/demand.rb |
solve-0.4.0 | lib/solve/demand.rb |
solve-0.4.0.rc1 | lib/solve/demand.rb |
solve-0.3.1 | lib/solve/demand.rb |