Class: Gem::StringSource

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygems/util/stringio.rb

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ StringSource

Returns a new instance of StringSource.



19
20
21
# File 'lib/rubygems/util/stringio.rb', line 19

def initialize(str)
  @string = str.dup
end

Instance Method Details

#read(count = nil) ⇒ Object Also known as: readpartial



23
24
25
26
27
28
29
30
31
# File 'lib/rubygems/util/stringio.rb', line 23

def read(count=nil)
  if count
    @string.slice!(0,count)
  else
    s = @string
    @string = ""
    s
  end
end