Class: Discordrb::Attachment
- Inherits:
-
Object
- Object
- Discordrb::Attachment
- Includes:
- IDObject
- Defined in:
- lib/discordrb/data/attachment.rb
Overview
An attachment to a message
Instance Attribute Summary collapse
-
#content_type ⇒ String?
readonly
The attachment's media type.
-
#description ⇒ String?
readonly
The attachment's description.
-
#duration_seconds ⇒ Float?
readonly
The duration of the voice message in seconds.
-
#ephemeral ⇒ true, false
(also: #ephemeral?)
readonly
Whether this attachment is ephemeral.
-
#filename ⇒ String
readonly
The attachment's filename.
-
#flags ⇒ Integer
readonly
The flags set on this attachment combined as a bitfield.
-
#height ⇒ Integer?
readonly
The height of an image file, in pixels, or
nil
if the file is not an image. -
#proxy_url ⇒ String
readonly
The attachment's proxy URL - I'm not sure what exactly this does, but I think it has something to do with CDNs.
-
#size ⇒ Integer
readonly
The attachment's file size in bytes.
-
#url ⇒ String
readonly
The CDN URL this attachment can be downloaded at.
-
#waveform ⇒ String?
readonly
The base64 encoded bytearray representing a sampled waveform for a voice message.
-
#width ⇒ Integer?
readonly
The width of an image file, in pixels, or
nil
if the file is not an image.
Attributes included from IDObject
Instance Method Summary collapse
-
#image? ⇒ true, false
Whether this file is an image file.
-
#message ⇒ Message?
The message this attachment object belongs to.
-
#snapshot ⇒ Snapshot?
The message snapshot this attachment object belongs to.
-
#spoiler? ⇒ true, false
Whether this file is tagged as a spoiler.
Methods included from IDObject
#==, #creation_time, synthesise
Instance Attribute Details
#content_type ⇒ String? (readonly)
Returns the attachment's media type.
31 32 33 |
# File 'lib/discordrb/data/attachment.rb', line 31 def content_type @content_type end |
#description ⇒ String? (readonly)
Returns the attachment's description.
28 29 30 |
# File 'lib/discordrb/data/attachment.rb', line 28 def description @description end |
#duration_seconds ⇒ Float? (readonly)
Returns the duration of the voice message in seconds.
38 39 40 |
# File 'lib/discordrb/data/attachment.rb', line 38 def duration_seconds @duration_seconds end |
#ephemeral ⇒ true, false (readonly) Also known as: ephemeral?
Returns whether this attachment is ephemeral.
34 35 36 |
# File 'lib/discordrb/data/attachment.rb', line 34 def ephemeral @ephemeral end |
#filename ⇒ String (readonly)
Returns the attachment's filename.
16 17 18 |
# File 'lib/discordrb/data/attachment.rb', line 16 def filename @filename end |
#flags ⇒ Integer (readonly)
Returns the flags set on this attachment combined as a bitfield.
44 45 46 |
# File 'lib/discordrb/data/attachment.rb', line 44 def flags @flags end |
#height ⇒ Integer? (readonly)
Returns the height of an image file, in pixels, or nil
if the file is not an image.
25 26 27 |
# File 'lib/discordrb/data/attachment.rb', line 25 def height @height end |
#proxy_url ⇒ String (readonly)
Returns the attachment's proxy URL - I'm not sure what exactly this does, but I think it has something to do with CDNs.
13 14 15 |
# File 'lib/discordrb/data/attachment.rb', line 13 def proxy_url @proxy_url end |
#size ⇒ Integer (readonly)
Returns the attachment's file size in bytes.
19 20 21 |
# File 'lib/discordrb/data/attachment.rb', line 19 def size @size end |
#url ⇒ String (readonly)
Returns the CDN URL this attachment can be downloaded at.
9 10 11 |
# File 'lib/discordrb/data/attachment.rb', line 9 def url @url end |
#waveform ⇒ String? (readonly)
Returns the base64 encoded bytearray representing a sampled waveform for a voice message.
41 42 43 |
# File 'lib/discordrb/data/attachment.rb', line 41 def waveform @waveform end |
#width ⇒ Integer? (readonly)
Returns the width of an image file, in pixels, or nil
if the file is not an image.
22 23 24 |
# File 'lib/discordrb/data/attachment.rb', line 22 def width @width end |
Instance Method Details
#image? ⇒ true, false
Returns whether this file is an image file.
72 73 74 |
# File 'lib/discordrb/data/attachment.rb', line 72 def image? !(@width.nil? || @height.nil?) end |
#message ⇒ Message?
Returns the message this attachment object belongs to.
82 83 84 |
# File 'lib/discordrb/data/attachment.rb', line 82 def @message unless @message.is_a?(Snapshot) end |
#snapshot ⇒ Snapshot?
Returns the message snapshot this attachment object belongs to.
87 88 89 |
# File 'lib/discordrb/data/attachment.rb', line 87 def snapshot @message unless @message.is_a?(Message) end |
#spoiler? ⇒ true, false
Returns whether this file is tagged as a spoiler.
77 78 79 |
# File 'lib/discordrb/data/attachment.rb', line 77 def spoiler? @filename.start_with? 'SPOILER_' end |