Class: Parse::Embeddings::ImageFetch::FetchedImage
- Inherits:
-
Struct
- Object
- Struct
- Parse::Embeddings::ImageFetch::FetchedImage
- Defined in:
- lib/parse/embeddings/image_fetch.rb
Overview
Value object for a fetched-and-verified image. mime_type is the
SNIFFED type (never the server-reported Content-Type). The
provider adapters consume this via #to_data_uri.
Instance Attribute Summary collapse
-
#bytes ⇒ Object
Returns the value of attribute bytes.
-
#mime_type ⇒ Object
Returns the value of attribute mime_type.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#inspect ⇒ Object
(also: #to_s)
Keep multi-MB image payloads out of exception messages and logs.
-
#to_data_uri ⇒ String
data:<mime>;base64,<payload>for provider wire bodies.
Instance Attribute Details
#bytes ⇒ Object
Returns the value of attribute bytes
68 69 70 |
# File 'lib/parse/embeddings/image_fetch.rb', line 68 def bytes @bytes end |
#mime_type ⇒ Object
Returns the value of attribute mime_type
68 69 70 |
# File 'lib/parse/embeddings/image_fetch.rb', line 68 def mime_type @mime_type end |
#url ⇒ Object
Returns the value of attribute url
68 69 70 |
# File 'lib/parse/embeddings/image_fetch.rb', line 68 def url @url end |
Instance Method Details
#inspect ⇒ Object Also known as: to_s
Keep multi-MB image payloads out of exception messages and logs.
75 76 77 78 |
# File 'lib/parse/embeddings/image_fetch.rb', line 75 def inspect "#<Parse::Embeddings::ImageFetch::FetchedImage mime_type=#{mime_type.inspect} " \ "bytes=#{bytes.respond_to?(:bytesize) ? bytes.bytesize : 0} url=#{url.inspect}>" end |
#to_data_uri ⇒ String
Returns data:<mime>;base64,<payload> for provider wire bodies.
70 71 72 |
# File 'lib/parse/embeddings/image_fetch.rb', line 70 def to_data_uri "data:#{mime_type};base64,#{Base64.strict_encode64(bytes)}" end |