Sha256: 39adf1193c819ab7833318875cc0c2150405939797cd5a27cbc6bffa0299b772
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
module Solve # @author Jamie Winsor <reset@riotgames.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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
solve-0.4.4 | lib/solve/demand.rb |
solve-0.4.3 | lib/solve/demand.rb |