Class: Solve::Solver::ConstraintTable

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConstraintTable

Returns a new instance of ConstraintTable.



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

def initialize
  @rows = Array.new
end

Instance Attribute Details

#rowsObject (readonly)

Returns the value of attribute rows.



4
5
6
# File 'lib/solve/solver/constraint_table.rb', line 4

def rows
  @rows
end

Instance Method Details

#add(dependency, source) ⇒ Array<ConstraintRow>

Parameters:

Returns:



14
15
16
# File 'lib/solve/solver/constraint_table.rb', line 14

def add(dependency, source)
  @rows << ConstraintRow.new(dependency, source)
end

#constraints_on_artifact(name) ⇒ Object



18
19
20
21
22
# File 'lib/solve/solver/constraint_table.rb', line 18

def constraints_on_artifact(name)
  @rows.select do |row|
    row.name == name
  end.map { |row| row.constraint }
end

#remove_constraints_from_source!(source) ⇒ Object



24
25
26
27
28
# File 'lib/solve/solver/constraint_table.rb', line 24

def remove_constraints_from_source!(source)
  from_source, others = @rows.partition { |row| row.source == source }
  @rows = others
  from_source
end