diff options
Diffstat (limited to 'lib/rubygems/util')
-rw-r--r-- | lib/rubygems/util/list.rb | 30 | ||||
-rw-r--r-- | lib/rubygems/util/stringio.rb | 34 |
2 files changed, 9 insertions, 55 deletions
diff --git a/lib/rubygems/util/list.rb b/lib/rubygems/util/list.rb index 9bc11fe334..6fa767646c 100644 --- a/lib/rubygems/util/list.rb +++ b/lib/rubygems/util/list.rb @@ -1,7 +1,13 @@ module Gem - List = Struct.new(:value, :tail) - class List + include Enumerable + attr_accessor :value, :tail + + def initialize(value = nil, tail = nil) + @value = value + @tail = tail + end + def each n = self while n @@ -11,25 +17,7 @@ module Gem end def to_a - ary = [] - n = self - while n - ary.unshift n.value - n = n.tail - end - - ary - end - - def find - n = self - while n - v = n.value - return v if yield(v) - n = n.tail - end - - nil + super.reverse end def prepend(value) diff --git a/lib/rubygems/util/stringio.rb b/lib/rubygems/util/stringio.rb deleted file mode 100644 index 2ea69617bc..0000000000 --- a/lib/rubygems/util/stringio.rb +++ /dev/null @@ -1,34 +0,0 @@ -class Gem::StringSink - def initialize - @string = "" - end - - attr_reader :string - - def write(s) - @string += s - s.size - end - - def set_encoding(enc) - @string.force_encoding enc - end -end - -class Gem::StringSource - def initialize(str) - @string = str.dup - end - - def read(count=nil) - if count - @string.slice!(0,count) - else - s = @string - @string = "" - s - end - end - - alias_method :readpartial, :read -end |