Class: Gem::StringSource
- Inherits:
-
Object
- Object
- Gem::StringSource
- Defined in:
- lib/rubygems/util/stringio.rb
Instance Method Summary collapse
-
#initialize(str) ⇒ StringSource
constructor
A new instance of StringSource.
- #read(count = nil) ⇒ Object (also: #readpartial)
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 |