Class: Gem::List

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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


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

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

Instance Attribute Details

#tailObject

Returns the value of attribute tail


5
6
7
# File 'lib/rubygems/util/list.rb', line 5

def tail
  @tail
end

#valueObject

Returns the value of attribute value


5
6
7
# File 'lib/rubygems/util/list.rb', line 5

def value
  @value
end

Class Method Details

.prepend(list, value) ⇒ Object


32
33
34
35
# File 'lib/rubygems/util/list.rb', line 32

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

Instance Method Details

#eachObject


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

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

#prepend(value) ⇒ Object


24
25
26
# File 'lib/rubygems/util/list.rb', line 24

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

#pretty_print(q) ⇒ Object

:nodoc:


28
29
30
# File 'lib/rubygems/util/list.rb', line 28

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

#to_aObject


20
21
22
# File 'lib/rubygems/util/list.rb', line 20

def to_a
  super.reverse
end