The RequirementList
is used to hold the requirements being considered while resolving a set of gems.
The RequirementList
acts like a queue where the oldest items are removed first.
Class Methods
::
lib/rubygems/resolver/requirement_list.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/rubygems/resolver/requirement_list.rb, line 15
def initialize
@exact = []
@list = []
end
Creates a new RequirementList
.
Instance Methods
#
lib/rubygems/resolver/requirement_list.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/rubygems/resolver/requirement_list.rb, line 28
def add(req)
if req.requirement.exact?
@exact.push req
else
@list.push req
end
req
end
Adds Resolver::DependencyRequest req
to this requirements list.
#
lib/rubygems/resolver/requirement_list.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/rubygems/resolver/requirement_list.rb, line 62
def empty?
@exact.empty? && @list.empty?
end
Is the list empty?
#
lib/rubygems/resolver/requirement_list.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/rubygems/resolver/requirement_list.rb, line 77
def next5
x = @exact[0,5]
x + @list[0,5 - x.size]
end
Returns the oldest five entries from the list.
#
lib/rubygems/resolver/requirement_list.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/rubygems/resolver/requirement_list.rb, line 69
def remove
return @exact.shift unless @exact.empty?
@list.shift
end
Remove the oldest DependencyRequest from the list.
#
lib/rubygems/resolver/requirement_list.rb
View on GitHub
# File tmp/rubies/ruby-3.1.3/lib/rubygems/resolver/requirement_list.rb, line 55
def size
@exact.size + @list.size
end
How many elements are in the list