Object
Class acts as a virtual file handle to a MIME multipart message body
All fields are required, the entry should be a string and is assumed to be XML.
# File lib/gdata/http/mime_body.rb, line 27 def initialize(entry, file, file_mime_type) @boundary = "END_OF_PART_#{rand(64000)}" entry = wrap_entry(entry, file_mime_type) closing_boundary = MimeBodyString.new("\r\n--#{@boundary}--") @parts = [entry, file, closing_boundary] @current_part = 0 end
Returns the content type of the message including boundary.
# File lib/gdata/http/mime_body.rb, line 54 def content_type return "multipart/related; boundary=\"#{@boundary}\"" end
Implement read so that this class can be treated as a stream.
# File lib/gdata/http/mime_body.rb, line 36 def read(bytes_requested) if @current_part >= @parts.length return false end buffer = @parts[@current_part].read(bytes_requested) until buffer.length == bytes_requested @current_part += 1 next_buffer = self.read(bytes_requested - buffer.length) break if not next_buffer buffer += next_buffer end return buffer end
Generated with the Darkfish Rdoc Generator 2.