Class: Ask::Content::File
Overview
An inline file block within a multi-modal message.
Instance Attribute Summary collapse
-
#data ⇒ String
readonly
The file content.
-
#filename ⇒ String?
readonly
Original filename.
-
#mime_type ⇒ String?
readonly
MIME type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(data:, mime_type: nil, filename: nil) ⇒ File
constructor
A new instance of File.
- #to_h ⇒ Object
Methods included from Block
Constructor Details
#initialize(data:, mime_type: nil, filename: nil) ⇒ File
Returns a new instance of File.
178 179 180 181 182 183 |
# File 'lib/ask/content.rb', line 178 def initialize(data:, mime_type: nil, filename: nil) @data = data @mime_type = mime_type @filename = filename freeze end |
Instance Attribute Details
#data ⇒ String (readonly)
Returns the file content.
167 168 169 |
# File 'lib/ask/content.rb', line 167 def data @data end |
#filename ⇒ String? (readonly)
Returns original filename.
173 174 175 |
# File 'lib/ask/content.rb', line 173 def filename @filename end |
#mime_type ⇒ String? (readonly)
Returns MIME type.
170 171 172 |
# File 'lib/ask/content.rb', line 170 def mime_type @mime_type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
185 186 187 188 |
# File 'lib/ask/content.rb', line 185 def ==(other) other.is_a?(File) && @data == other.data && @mime_type == other.mime_type && @filename == other.filename end |
#hash ⇒ Object
191 192 193 |
# File 'lib/ask/content.rb', line 191 def hash [@data, @mime_type, @filename].hash end |
#to_h ⇒ Object
195 196 197 |
# File 'lib/ask/content.rb', line 195 def to_h { type: "file", data: @data, mime_type: @mime_type, filename: @filename } end |