class HTTP::Response::StringBody
object.
A Body class that wraps a String, rather than a the client
def each
def each yield @contents end
def initialize(contents)
def initialize(contents) @contents = contents @streaming = nil @streaming_offset = 0 end
def inspect
def inspect "#<#{self.class}:#{object_id.to_s(16)}>" end
def readpartial(size = @contents.length)
-
(String, nil)
- the next `size` octets part of the
def readpartial(size = @contents.length) stream! return nil if @streaming_offset >= @contents.length @contents[@streaming_offset, size].tap do |part| @streaming_offset += (part.length + 1) end end
def stream!
def stream! fail StateError, "body has already been consumed" if @streaming == false @streaming = true end
def to_s
-
(String)
- eagerly consume the entire body as a string
def to_s @contents end