Class: Gem::SourceList
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Instance Chain: 
          self,
          Enumerable
         | |
| Inherits: | Object | 
| Defined in: | lib/rubygems/source_list.rb | 
Overview
The SourceList represents the sources rubygems has been configured to use. A source may be created from an array of sources:
Gem::SourceList.from %w[https://rubygems.example https://internal.example]Or by adding them:
sources = Gem::SourceList.new
sources << 'https://rubygems.example'The most common way to get a SourceList is sources.
Class Method Summary
- 
    
      .from(ary)  
    
    Creates a new SourceListfrom an array of sources.
- 
    
      .new  ⇒ SourceList 
    
    constructor
    Creates a new SourceList.
Instance Attribute Summary
- 
    
      #empty?  ⇒ Boolean 
    
    readonly
    Returns true if there are no sources in this SourceList.
- 
    
      #sources  
    
    readonly
    The sources in this list. 
Instance Method Summary
- 
    
      #<<(obj)  
    
    Appends objto the source list which may be aSource, URI or URI String.
- 
    
      #clear  
    
    Removes all sources from the SourceList.
- 
    
      #delete(source)  
    
    Deletes sourcefrom the source list which may be aSourceor a URI.
- 
    
      #each  
    
    Yields each source URI in the list. 
- 
    
      #each_source(&b)  
    
    Yields each source in the list. 
- 
    
      #first  
    
    Returns the first source in the list. 
- 
    
      #include?(other)  ⇒ Boolean 
    
    Returns true if this source list includes otherwhich may be aSourceor a source URI.
- 
    
      #replace(other)  
    
    Replaces this SourceListwith the sources inotherSee #<< for acceptable items inother.
- 
    
      #to_a  
      (also: #to_ary)
    
    Returns an Array of source URI Strings. 
- 
    
      #to_ary  
    
    Alias for #to_a. 
- #==(other) Internal use only
- #initialize_copy(other) Internal use only
Constructor Details
    .new  ⇒ SourceList 
  
Creates a new SourceList
# File 'lib/rubygems/source_list.rb', line 22
def initialize @sources = [] end
Class Method Details
.from(ary)
Creates a new SourceList from an array of sources.
Instance Attribute Details
    #empty?  ⇒ Boolean  (readonly)
  
Returns true if there are no sources in this SourceList.
# File 'lib/rubygems/source_list.rb', line 100
def empty? @sources.empty? end
#sources (readonly)
The sources in this list
# File 'lib/rubygems/source_list.rb', line 29
attr_reader :sources
Instance Method Details
#<<(obj)
Appends obj to the source list which may be a Source, URI or URI String.
#==(other)
# File 'lib/rubygems/source_list.rb', line 104
def ==(other) # :nodoc: to_a == other end
#clear
Removes all sources from the SourceList.
# File 'lib/rubygems/source_list.rb', line 79
def clear @sources.clear end
#delete(source)
Deletes source from the source list which may be a Source or a URI.
#each
Yields each source URI in the list.
# File 'lib/rubygems/source_list.rb', line 86
def each @sources.each {|s| yield s.uri.to_s } end
#each_source(&b)
Yields each source in the list.
# File 'lib/rubygems/source_list.rb', line 93
def each_source(&b) @sources.each(&b) end
#first
Returns the first source in the list.
# File 'lib/rubygems/source_list.rb', line 120
def first @sources.first end
    #include?(other)  ⇒ Boolean 
  
Returns true if this source list includes other which may be a Source or a source URI.
#initialize_copy(other)
# File 'lib/rubygems/source_list.rb', line 42
def initialize_copy(other) # :nodoc: @sources = @sources.dup end
#replace(other)
Replaces this SourceList with the sources in other  See #<< for acceptable items in other.
#to_a Also known as: #to_ary
Returns an Array of source URI Strings.
# File 'lib/rubygems/source_list.rb', line 111
def to_a @sources.map {|x| x.uri.to_s } end
#to_ary
Alias for #to_a.
# File 'lib/rubygems/source_list.rb', line 115
alias_method :to_ary, :to_a