Class: Solve::Demand

Inherits:
Object
  • Object
show all
Defined in:
lib/solve/demand.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(solver, name, constraint = ">= 0.0.0") ⇒ Demand

Returns a new instance of Demand.

Parameters:



21
22
23
24
25
26
27
28
29
# File 'lib/solve/demand.rb', line 21

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

#constraintSolve::Constraint (readonly)

The acceptable constraint of the artifact this demand is for

Returns:



16
17
18
# File 'lib/solve/demand.rb', line 16

def constraint
  @constraint
end

#nameString (readonly)

The name of the artifact this demand is for

Returns:

  • (String)


11
12
13
# File 'lib/solve/demand.rb', line 11

def name
  @name
end

#solverSolve::Solver (readonly)

A reference to the solver this demand belongs to

Returns:



6
7
8
# File 'lib/solve/demand.rb', line 6

def solver
  @solver
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



46
47
48
49
50
# File 'lib/solve/demand.rb', line 46

def ==(other)
  other.is_a?(self.class) &&
    self.name == other.name &&
    self.constraint == other.constraint
end

#deleteSolve::Demand?

Remove this demand from the solver it belongs to

Returns:



34
35
36
37
38
39
40
# File 'lib/solve/demand.rb', line 34

def delete
  unless solver.nil?
    result = solver.remove_demand(self)
    @solver = nil
    result
  end
end

#to_sObject



42
43
44
# File 'lib/solve/demand.rb', line 42

def to_s
  "#{name} (#{constraint})"
end