aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/resolver/requirement_list.rb
blob: 04e437b2a9018de6d660091a9688701cbd1b87c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
##
# Used internally to hold the requirements being considered
# while attempting to find a proper activation set.

class Gem::Resolver::RequirementList

  include Enumerable

  def initialize
    @list = []
  end

  def initialize_copy(other)
    @list = @list.dup
  end

  def add(req)
    @list.push req
    req
  end

  ##
  # Enumerates requirements in the list

  def each # :nodoc:
    return enum_for __method__ unless block_given?

    @list.each do |requirement|
      yield requirement
    end
  end

  def empty?
    @list.empty?
  end

  def remove
    @list.shift
  end

  def next5
    @list[0,5]
  end
end