A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.ruby-lang.org/en/3.4/RubyVM/../Gem/SourceList.html below:

class Gem::SourceList - Documentation for Ruby 3.4

  1. Gem::
  2. SourceList
class Gem::SourceList

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 Gem.sources.

Attributes Public Class Methods

Source

def self.from(ary)
  list = new

  list.replace ary

  list
end

Creates a new SourceList from an array of sources.

Source

def initialize
  @sources = []
end

Creates a new SourceList

Public Instance Methods

Source

def <<(obj)
  src = case obj
        when Gem::Source
          obj
        else
          Gem::Source.new(obj)
  end

  @sources << src unless @sources.include?(src)
  src
end

Appends obj to the source list which may be a Gem::Source, Gem::URI or URI String.

Source

def clear
  @sources.clear
end

Removes all sources from the SourceList.

Source

def delete(source)
  if source.is_a? Gem::Source
    @sources.delete source
  else
    @sources.delete_if {|x| x.uri.to_s == source.to_s }
  end
end

Deletes source from the source list which may be a Gem::Source or a URI.

Source

def each
  @sources.each {|s| yield s.uri.to_s }
end

Yields each source URI in the list.

Source

def each_source(&b)
  @sources.each(&b)
end

Yields each source in the list.

Source

def empty?
  @sources.empty?
end

Returns true if there are no sources in this SourceList.

Source

def first
  @sources.first
end

Returns the first source in the list.

Source

def include?(other)
  if other.is_a? Gem::Source
    @sources.include? other
  else
    @sources.find {|x| x.uri.to_s == other.to_s }
  end
end

Returns true if this source list includes other which may be a Gem::Source or a source URI.

Source

def replace(other)
  clear

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

  self
end

Replaces this SourceList with the sources in other See << for acceptable items in other.

Source

def to_a
  @sources.map {|x| x.uri.to_s }
end

Returns an Array of source URI Strings.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4