Class: Solve::Solver::ConstraintTable
- Inherits:
-
Object
- Object
- Solve::Solver::ConstraintTable
- Defined in:
- lib/solve/solver/constraint_table.rb
Instance Attribute Summary collapse
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #add(dependency, source) ⇒ Array<ConstraintRow>
- #constraints_on_artifact(name) ⇒ Object
-
#initialize ⇒ ConstraintTable
constructor
A new instance of ConstraintTable.
- #remove_constraints_from_source!(source) ⇒ Object
Constructor Details
#initialize ⇒ ConstraintTable
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
#rows ⇒ Object (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>
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 |