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 = Semverse::DEFAULT_CONSTRAINT) ⇒ Demand

Returns a new instance of Demand.

Parameters:



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

def initialize(solver, name, constraint = Semverse::DEFAULT_CONSTRAINT)
  @solver     = solver
  @name       = name
  @constraint = Semverse::Constraint.coerce(constraint)
end

Instance Attribute Details

#constraintSemverse::Constraint (readonly)

The acceptable constraint of the artifact this demand is for

Returns:

  • (Semverse::Constraint)


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::RubySolver, Solve::GecodeSolver (readonly)

A reference to the solver this demand belongs to



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

def solver
  @solver
end

Instance Method Details

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



31
32
33
34
35
# File 'lib/solve/demand.rb', line 31

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

#to_sObject



27
28
29
# File 'lib/solve/demand.rb', line 27

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