Class: GData::HTTP::MimeBodyString
- Inherits:
-
Object
- Object
- GData::HTTP::MimeBodyString
- Defined in:
- lib/gdata/http/mime_body.rb
Overview
Class makes a string into a stream-like object
Instance Method Summary collapse
-
#initialize(source_string) ⇒ MimeBodyString
constructor
A new instance of MimeBodyString.
-
#read(bytes_requested) ⇒ Object
Implement read so that this class can be treated as a stream.
Constructor Details
#initialize(source_string) ⇒ MimeBodyString
Returns a new instance of MimeBodyString.
75 76 77 78 |
# File 'lib/gdata/http/mime_body.rb', line 75 def initialize(source_string) @string = source_string @bytes_read = 0 end |
Instance Method Details
#read(bytes_requested) ⇒ Object
Implement read so that this class can be treated as a stream.
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/gdata/http/mime_body.rb', line 81 def read(bytes_requested) if @bytes_read == @string.length return false elsif bytes_requested > @string.length - @bytes_read bytes_requested = @string.length - @bytes_read end buffer = @string[@bytes_read, bytes_requested] @bytes_read += bytes_requested return buffer end |