Class: Gem::SourceList
- Inherits:
-
Object
- Object
- Gem::SourceList
- Defined in:
- lib/rubygems/source_list.rb
Instance Attribute Summary collapse
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(obj) ⇒ Object
- #==(other) ⇒ Object
- #delete(uri) ⇒ Object
- #each ⇒ Object
- #each_source(&b) ⇒ Object
- #first ⇒ Object
- #include?(other) ⇒ Boolean
-
#initialize ⇒ SourceList
constructor
A new instance of SourceList.
- #initialize_copy(other) ⇒ Object
- #replace(other) ⇒ Object
- #to_a ⇒ Object (also: #to_ary)
Constructor Details
#initialize ⇒ SourceList
Returns a new instance of SourceList.
4 5 6 |
# File 'lib/rubygems/source_list.rb', line 4 def initialize @sources = [] end |
Instance Attribute Details
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
8 9 10 |
# File 'lib/rubygems/source_list.rb', line 8 def sources @sources end |
Class Method Details
.from(ary) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# 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 |
Instance Method Details
#<<(obj) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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) ⇒ Object
58 59 60 |
# File 'lib/rubygems/source_list.rb', line 58 def ==(other) to_a == other end |
#delete(uri) ⇒ Object
80 81 82 83 84 85 86 |
# 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 ⇒ Object
50 51 52 |
# File 'lib/rubygems/source_list.rb', line 50 def each @sources.each { |s| yield s.uri.to_s } end |
#each_source(&b) ⇒ Object
54 55 56 |
# File 'lib/rubygems/source_list.rb', line 54 def each_source(&b) @sources.each(&b) end |
#first ⇒ Object
68 69 70 |
# File 'lib/rubygems/source_list.rb', line 68 def first @sources.first end |
#include?(other) ⇒ Boolean
72 73 74 75 76 77 78 |
# 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) ⇒ Object
22 23 24 |
# File 'lib/rubygems/source_list.rb', line 22 def initialize_copy(other) @sources = @sources.dup end |
#replace(other) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/rubygems/source_list.rb', line 40 def replace(other) @sources.clear other.each do |x| self << x end self end |
#to_a ⇒ Object Also known as: to_ary
62 63 64 |
# File 'lib/rubygems/source_list.rb', line 62 def to_a @sources.map { |x| x.uri.to_s } end |