class GData::HTTP::MimeBodyString
Class makes a string into a stream-like object
Public Class Methods
new(source_string)
click to toggle source
# File lib/gdata/http/mime_body.rb, line 75 def initialize(source_string) @string = source_string @bytes_read = 0 end
Public Instance Methods
read(bytes_requested)
click to toggle source
Implement read so that this class can be treated as a stream.
# 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