Module: OllamaChat::Utils::Fetcher::ResponseMetadata
- Defined in:
- lib/ollama_chat/utils/fetcher.rb
Overview
A module that extends IO objects with content type metadata and expiration tracking.
This module provides a way to attach MIME content type information and cache expiration details to IO objects, enabling them to carry metadata about their source and caching behavior. It is primarily used by fetcher implementations to decorate response objects with additional context for processing and caching decisions.
Instance Attribute Summary collapse
-
#content_type ⇒ String
The content type of the object.
-
#ex ⇒ Integer
The expiry value in seconds.
-
#response_reason ⇒ String
The HTTP response reason phrase.
-
#response_status ⇒ Integer
The HTTP response status code.
Class Method Summary collapse
-
.failed(msg) ⇒ StringIO
The failed method creates a StringIO object with a text/plain content type.
Instance Method Summary collapse
-
#http? ⇒ Boolean
Returns true if the metadata belongs to an HTTP response.
Instance Attribute Details
#content_type ⇒ String
Returns the content type of the object.
39 40 41 |
# File 'lib/ollama_chat/utils/fetcher.rb', line 39 def content_type @content_type end |
#ex ⇒ Integer
Returns the expiry value in seconds.
43 44 45 |
# File 'lib/ollama_chat/utils/fetcher.rb', line 43 def ex @ex end |
#response_reason ⇒ String
Returns the HTTP response reason phrase.
51 52 53 |
# File 'lib/ollama_chat/utils/fetcher.rb', line 51 def response_reason @response_reason end |
#response_status ⇒ Integer
Returns the HTTP response status code.
47 48 49 |
# File 'lib/ollama_chat/utils/fetcher.rb', line 47 def response_status @response_status end |
Class Method Details
.failed(msg) ⇒ StringIO
The failed method creates a StringIO object with a text/plain content type.
This method is used to generate a failed response object that can be used when an operation does not succeed. It initializes a new StringIO object and extends it with the current class, setting its content type to text/plain.
73 74 75 76 77 78 79 |
# File 'lib/ollama_chat/utils/fetcher.rb', line 73 def self.failed(msg) object = StringIO.new.extend(self) object.write msg object.rewind object.content_type = MIME::Types['text/plain'].first object end |
Instance Method Details
#http? ⇒ Boolean
Returns true if the metadata belongs to an HTTP response.
This is determined by the presence of a response status code.
59 60 61 |
# File 'lib/ollama_chat/utils/fetcher.rb', line 59 def http? !response_status.nil? end |