Class: Solve::Solver::ConstraintTable
- Inherits:
-
Object
- Object
- Solve::Solver::ConstraintTable
- Defined in:
- lib/solve/solver/constraint_table.rb
Overview
Instance Attribute Summary collapse
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #add(package, constraint, source) ⇒ Object
- #constraints_on_package(package) ⇒ 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.
8 9 10 |
# File 'lib/solve/solver/constraint_table.rb', line 8 def initialize @rows = Array.new end |
Instance Attribute Details
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
6 7 8 |
# File 'lib/solve/solver/constraint_table.rb', line 6 def rows @rows end |
Instance Method Details
#add(package, constraint, source) ⇒ Object
12 13 14 |
# File 'lib/solve/solver/constraint_table.rb', line 12 def add(package, constraint, source) @rows << ConstraintRow.new(package, constraint, source) end |
#constraints_on_package(package) ⇒ Object
16 17 18 19 20 |
# File 'lib/solve/solver/constraint_table.rb', line 16 def constraints_on_package(package) @rows.select do |row| row.package == package end.map { |row| row.constraint } end |
#remove_constraints_from_source!(source) ⇒ Object
22 23 24 |
# File 'lib/solve/solver/constraint_table.rb', line 22 def remove_constraints_from_source!(source) @rows.reject! { |row| row.source == source } end |