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

Returns a new instance of List.



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

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

Instance Attribute Details

#tailObject

Returns the value of attribute tail



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

def tail
  @tail
end

#valueObject

Returns the value of attribute value



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

def value
  @value
end

Class Method Details

.prepend(list, value) ⇒ Object



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

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

Instance Method Details

#eachObject



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

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

#prepend(value) ⇒ Object



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

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

#pretty_print(q) ⇒ Object

:nodoc:



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

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

#to_aObject



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

def to_a
  super.reverse
end