Class: Doubleshot::Resolver::GemResolver::Solver::VariableTable
- Defined in:
- lib/doubleshot/resolver/gem_resolver/solver/variable_table.rb
Instance Attribute Summary collapse
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #add(artifact, source) ⇒ Object
- #all_after(artifact) ⇒ Object
- #all_from_source(source) ⇒ Object
- #before(artifact) ⇒ Object
- #find_artifact(artifact) ⇒ Object
- #first_unbound ⇒ Object
-
#initialize ⇒ VariableTable
constructor
A new instance of VariableTable.
- #remove_all_with_only_this_source!(source) ⇒ Object
Constructor Details
#initialize ⇒ VariableTable
Returns a new instance of VariableTable.
8 9 10 |
# File 'lib/doubleshot/resolver/gem_resolver/solver/variable_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/doubleshot/resolver/gem_resolver/solver/variable_table.rb', line 6 def rows @rows end |
Instance Method Details
#add(artifact, source) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/doubleshot/resolver/gem_resolver/solver/variable_table.rb', line 14 def add(artifact, source) row = rows.detect { |row| row.artifact == artifact } if row.nil? @rows << VariableRow.new(artifact, source) else row.add_source(source) end end |
#all_after(artifact) ⇒ Object
51 52 53 54 |
# File 'lib/doubleshot/resolver/gem_resolver/solver/variable_table.rb', line 51 def all_after(artifact) artifact_index = @rows.index { |row| row.artifact == artifact } @rows[(artifact_index+1)..-1] end |
#all_from_source(source) ⇒ Object
40 41 42 |
# File 'lib/doubleshot/resolver/gem_resolver/solver/variable_table.rb', line 40 def all_from_source(source) @rows.select { |row| row.sources.include?(source) } end |
#before(artifact) ⇒ Object
45 46 47 48 |
# File 'lib/doubleshot/resolver/gem_resolver/solver/variable_table.rb', line 45 def before(artifact) artifact_index = @rows.index { |row| row.artifact == artifact } (artifact_index == 0) ? nil : @rows[artifact_index - 1] end |
#find_artifact(artifact) ⇒ Object
28 29 30 |
# File 'lib/doubleshot/resolver/gem_resolver/solver/variable_table.rb', line 28 def find_artifact(artifact) @rows.detect { |row| row.artifact == artifact } end |
#first_unbound ⇒ Object
23 24 25 |
# File 'lib/doubleshot/resolver/gem_resolver/solver/variable_table.rb', line 23 def first_unbound @rows.detect { |row| row.bound? == false } end |
#remove_all_with_only_this_source!(source) ⇒ Object
33 34 35 36 37 |
# File 'lib/doubleshot/resolver/gem_resolver/solver/variable_table.rb', line 33 def remove_all_with_only_this_source!(source) with_only_this_source, others = @rows.partition { |row| row.sources == [source] } @rows = others with_only_this_source end |