Class: Doubleshot::Resolver::GemResolver::Solver::ConstraintTable

Inherits:
Object
  • Object
show all
Defined in:
lib/doubleshot/resolver/gem_resolver/solver/constraint_table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConstraintTable

Returns a new instance of ConstraintTable.



8
9
10
# File 'lib/doubleshot/resolver/gem_resolver/solver/constraint_table.rb', line 8

def initialize
  @rows = Array.new
end

Instance Attribute Details

#rowsObject (readonly)

Returns the value of attribute rows.



6
7
8
# File 'lib/doubleshot/resolver/gem_resolver/solver/constraint_table.rb', line 6

def rows
  @rows
end

Instance Method Details

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

Parameters:

Returns:



16
17
18
# File 'lib/doubleshot/resolver/gem_resolver/solver/constraint_table.rb', line 16

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

#constraints_on_artifact(name) ⇒ Object



20
21
22
23
24
# File 'lib/doubleshot/resolver/gem_resolver/solver/constraint_table.rb', line 20

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

#remove_constraints_from_source!(source) ⇒ Object



26
27
28
29
30
# File 'lib/doubleshot/resolver/gem_resolver/solver/constraint_table.rb', line 26

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