sig/discorb/attachment.rbs
module Discorb
#
# Represents a attachment file.
class Attachment
#
# Creates a new attachment.
#
# @param [#read, String] source The Source of the attachment.
# @param [String] filename The filename of the attachment. If not set, path or object_id of the IO is used.
# @param [String] description The description of the attachment.
# @param [String] content_type The content type of the attachment. If not set, it is guessed from the filename.
# If failed to guess, it is set to `application/octet-stream`.
# @param [Boolean] will_close Whether the IO will be closed after the attachment is sent.
def initialize: (
untyped | String source,
?String? filename,
?description: String?,
?content_type: String?,
?will_close: bool
) -> void
#
# Initializes the object from a hash.
# @private
def initialize_hash: (untyped data) -> untyped
%a{pure}
def inspect: -> String
#
# Convert the attachment to hash.
#
# @return [Hash] The action hash.
%a{pure}
def to_hash: -> Discorb::json
#
# Creates a new file from a hash.
# @private
def self.from_hash: (untyped data) -> untyped
#
# Creates a new file from a string.
#
# @param [String] string The string to create the file from.
# @param [String] filename The filename of the file. object_id of the string is used if not set.
# @param [String] content_type The content type of the file. If not set, it is guessed from the filename.
#
# @return [Discorb::Attachment] The new file.
def self.from_string: (
String string,
?String? filename,
?content_type: String?,
?description: untyped
) -> Discorb::Attachment
# @return [#read] The file content.
attr_reader io: untyped
# @return [String] The attachment filename.
attr_reader filename: String
# @return [String] The attachment content type.
attr_reader content_type: String
# @return [String] The attachment description.
attr_reader description: String?
# @return [Discorb::Snowflake] The attachment id.
attr_reader id: Discorb::Snowflake
# @return [Integer] The attachment size in bytes.
attr_reader size: Integer
# @return [String] The attachment url.
attr_reader url: String
# @return [String] The attachment proxy url.
attr_reader proxy_url: String
# @return [Integer] The image height.
# @return [nil] If the attachment is not an image.
attr_reader height: Integer?
# @return [Integer] The image width.
# @return [nil] If the attachment is not an image.
attr_reader width: Integer?
# @return [:client, :discord] The attachment was created by.
attr_reader created_by: :client | :discord
# @private
# @return [Boolean] Whether the attachment will be closed after it is sent.
attr_reader will_close: bool
# @return [Boolean] whether the file is an image.
attr_reader image?: bool
end
end