Class: Gem::List

Inherits:
Object show all
Includes:
Enumerable
Defined in:
lib/rubygems/util/list.rb

Overview

The Gem::List class is currently unused and will be removed in the next major rubygems version

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#to_set

Constructor Details

#initialize(value = nil, tail = nil) ⇒ List

Returns a new instance of List.



9
10
11
12
# File 'lib/rubygems/util/list.rb', line 9

def initialize(value = nil, tail = nil)
  @value = value
  @tail = tail
end

Instance Attribute Details

#tailObject

Returns the value of attribute tail.



7
8
9
# File 'lib/rubygems/util/list.rb', line 7

def tail
  @tail
end

#valueObject

Returns the value of attribute value.



7
8
9
# File 'lib/rubygems/util/list.rb', line 7

def value
  @value
end

Class Method Details

.prepend(list, value) ⇒ Object



34
35
36
37
# File 'lib/rubygems/util/list.rb', line 34

def self.prepend(list, value)
  return List.new(value) unless list
  List.new value, list
end

Instance Method Details

#eachObject



14
15
16
17
18
19
20
# File 'lib/rubygems/util/list.rb', line 14

def each
  n = self
  while n
    yield n.value
    n = n.tail
  end
end

#prepend(value) ⇒ Object



26
27
28
# File 'lib/rubygems/util/list.rb', line 26

def prepend(value)
  List.new value, self
end

#pretty_print(q) ⇒ Object

:nodoc:



30
31
32
# File 'lib/rubygems/util/list.rb', line 30

def pretty_print(q) # :nodoc:
  q.pp to_a
end

#to_aObject



22
23
24
# File 'lib/rubygems/util/list.rb', line 22

def to_a
  super.reverse
end