class Discorb::File
Represents a file to send as an attachment.
Attributes
content_type[RW]
@return [String] The content type of the file. If not set, it is guessed from the filename.
filename[RW]
@return [String] The filename of the file. If not set, path or object_id of the IO is used.
io[RW]
@return [#read] The IO of the file.
Public Class Methods
new(io, filename = nil, content_type: nil)
click to toggle source
# File lib/discorb/file.rb, line 62 def initialize(io, filename = nil, content_type: nil) @io = io @filename = filename || (io.respond_to?(:path) ? io.path : io.object_id) @content_type = content_type || MIME::Types.type_for(@filename)[0].to_s @content_type = "application/octet-stream" if @content_type == "" end