Class: Solve::Demand
- Inherits:
-
Object
- Object
- Solve::Demand
- Defined in:
- lib/solve/demand.rb
Overview
Instance Attribute Summary collapse
-
#constraint ⇒ Solve::Constraint
readonly
The acceptable constraint of the artifact this demand is for.
-
#name ⇒ String
readonly
The name of the artifact this demand is for.
-
#solver ⇒ Solve::Solver
readonly
A reference to the solver this demand belongs to.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#delete ⇒ Solve::Demand?
Remove this demand from the solver it belongs to.
-
#initialize(solver, name, constraint = ">= 0.0.0") ⇒ Demand
constructor
A new instance of Demand.
- #to_s ⇒ Object
Constructor Details
#initialize(solver, name, constraint = ">= 0.0.0") ⇒ Demand
Returns a new instance of Demand.
22 23 24 25 26 27 28 29 30 |
# File 'lib/solve/demand.rb', line 22 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 |
Instance Attribute Details
#constraint ⇒ Solve::Constraint (readonly)
The acceptable constraint of the artifact this demand is for
17 18 19 |
# File 'lib/solve/demand.rb', line 17 def constraint @constraint end |
#name ⇒ String (readonly)
The name of the artifact this demand is for
12 13 14 |
# File 'lib/solve/demand.rb', line 12 def name @name end |
#solver ⇒ Solve::Solver (readonly)
A reference to the solver this demand belongs to
7 8 9 |
# File 'lib/solve/demand.rb', line 7 def solver @solver end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
47 48 49 50 51 |
# File 'lib/solve/demand.rb', line 47 def ==(other) other.is_a?(self.class) && self.name == other.name && self.constraint == other.constraint end |
#delete ⇒ Solve::Demand?
Remove this demand from the solver it belongs to
35 36 37 38 39 40 41 |
# File 'lib/solve/demand.rb', line 35 def delete unless solver.nil? result = solver.remove_demand(self) @solver = nil result end end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/solve/demand.rb', line 43 def to_s "#{name} (#{constraint})" end |