class Gem::SourceList

Attributes

sources[R]

Public Class Methods

from(ary) click to toggle source
# File lib/rubygems/source_list.rb, line 10
def self.from(ary)
  list = new

  if ary
    ary.each do |x|
      list << x
    end
  end

  return list
end
new() click to toggle source
# File lib/rubygems/source_list.rb, line 4
def initialize
  @sources = []
end

Public Instance Methods

<<(obj) click to toggle source
# File lib/rubygems/source_list.rb, line 26
def <<(obj)
  src = case obj
        when URI
          Gem::Source.new(obj)
        when Gem::Source
          obj
        else
          Gem::Source.new(URI.parse(obj))
        end

  @sources << src
  src
end
==(other) click to toggle source
# File lib/rubygems/source_list.rb, line 58
def ==(other)
  to_a == other
end
delete(uri) click to toggle source
# File lib/rubygems/source_list.rb, line 80
def delete(uri)
  if uri.kind_of? Gem::Source
    @sources.delete uri
  else
    @sources.delete_if { |x| x.uri.to_s == uri.to_s }
  end
end
each() { |uri.to_s| ... } click to toggle source
# File lib/rubygems/source_list.rb, line 50
def each
  @sources.each { |s| yield s.uri.to_s }
end
each_source(&b) click to toggle source
# File lib/rubygems/source_list.rb, line 54
def each_source(&b)
  @sources.each(&b)
end
first() click to toggle source
# File lib/rubygems/source_list.rb, line 68
def first
  @sources.first
end
include?(other) click to toggle source
# File lib/rubygems/source_list.rb, line 72
def include?(other)
  if other.kind_of? Gem::Source
    @sources.include? other
  else
    @sources.find { |x| x.uri.to_s == other.to_s }
  end
end
initialize_copy(other) click to toggle source
# File lib/rubygems/source_list.rb, line 22
def initialize_copy(other)
  @sources = @sources.dup
end
replace(other) click to toggle source
# File lib/rubygems/source_list.rb, line 40
def replace(other)
  @sources.clear

  other.each do |x|
    self << x
  end

  self
end
to_a() click to toggle source
# File lib/rubygems/source_list.rb, line 62
def to_a
  @sources.map { |x| x.uri.to_s }
end
Also aliased as: to_ary
to_ary()
Alias for: to_a