123456789_123456789_123456789_123456789_123456789_

Class: Gem::List

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Enumerable
Inherits: Object
Defined in: lib/rubygems/util/list.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(value = nil, tail = nil) ⇒ List

[ GitHub ]

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

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

Class Method Details

.prepend(list, value)

[ GitHub ]

  
# 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 Attribute Details

#tail (rw)

[ GitHub ]

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

attr_accessor :value, :tail

#value (rw)

[ GitHub ]

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

attr_accessor :value, :tail

Instance Method Details

#each

[ GitHub ]

  
# File 'lib/rubygems/util/list.rb', line 13

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

#prepend(value)

[ GitHub ]

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

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

#pretty_print(q)

This method is for internal use only.
[ GitHub ]

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

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

#to_a

[ GitHub ]

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

def to_a
  super.reverse
end