Class: Rubycord::Attachment
- Inherits:
-
Object
- Object
- Rubycord::Attachment
- Includes:
- AttachmentAttributes, IDObject
- Defined in:
- lib/rubycord/data/attachment.rb
Overview
An attachment to a message
Constant Summary
Constants included from AttachmentAttributes
Rubycord::AttachmentAttributes::FLAGS
Instance Attribute Summary collapse
-
#content_type ⇒ String?
readonly
The attachment's media type.
-
#description ⇒ String?
readonly
The attachment's description.
-
#duration_secs ⇒ Float?
readonly
The duration of the audio file (currently for voice messages).
-
#filename ⇒ String
readonly
The attachment's filename.
-
#height ⇒ Integer?
readonly
The height of an image file, in pixels, or
nil
if the file is not an image. -
#message ⇒ Message
readonly
The message this attachment belongs to.
-
#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.
-
#title ⇒ String?
readonly
The attachment's title.
-
#url ⇒ String
readonly
The CDN URL this attachment can be downloaded at.
-
#waveform ⇒ String?
readonly
Base64 encoded bytearray representing a sampled waveform (currently for voice messages).
-
#width ⇒ Integer?
readonly
The width of an image file, in pixels, or
nil
if the file is not an image.
Attributes included from AttachmentAttributes
Attributes included from IDObject
Instance Method Summary collapse
-
#audio? ⇒ true, false
Whether this file is an audio file.
-
#ephemeral? ⇒ true, false
Whether this attachment is ephemeral.
-
#image? ⇒ true, false
Whether this file is an image file.
Methods included from AttachmentAttributes
Methods included from IDObject
#==, #creation_time, synthesise
Instance Attribute Details
#content_type ⇒ String? (readonly)
Returns the attachment's media type.
44 45 46 |
# File 'lib/rubycord/data/attachment.rb', line 44 def content_type @content_type end |
#description ⇒ String? (readonly)
Returns the attachment's description.
41 42 43 |
# File 'lib/rubycord/data/attachment.rb', line 41 def description @description end |
#duration_secs ⇒ Float? (readonly)
Returns the duration of the audio file (currently for voice messages).
63 64 65 |
# File 'lib/rubycord/data/attachment.rb', line 63 def duration_secs @duration_secs end |
#filename ⇒ String (readonly)
Returns the attachment's filename.
35 36 37 |
# File 'lib/rubycord/data/attachment.rb', line 35 def filename @filename end |
#height ⇒ Integer? (readonly)
Returns the height of an image file, in pixels, or nil
if the file is not an image.
57 58 59 |
# File 'lib/rubycord/data/attachment.rb', line 57 def height @height end |
#message ⇒ Message (readonly)
Returns the message this attachment belongs to.
32 33 34 |
# File 'lib/rubycord/data/attachment.rb', line 32 def @message 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.
54 55 56 |
# File 'lib/rubycord/data/attachment.rb', line 54 def proxy_url @proxy_url end |
#size ⇒ Integer (readonly)
Returns the attachment's file size in bytes.
47 48 49 |
# File 'lib/rubycord/data/attachment.rb', line 47 def size @size end |
#title ⇒ String? (readonly)
Returns the attachment's title.
38 39 40 |
# File 'lib/rubycord/data/attachment.rb', line 38 def title @title end |
#url ⇒ String (readonly)
Returns the CDN URL this attachment can be downloaded at.
50 51 52 |
# File 'lib/rubycord/data/attachment.rb', line 50 def url @url end |
#waveform ⇒ String? (readonly)
Returns base64 encoded bytearray representing a sampled waveform (currently for voice messages).
66 67 68 |
# File 'lib/rubycord/data/attachment.rb', line 66 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.
60 61 62 |
# File 'lib/rubycord/data/attachment.rb', line 60 def width @width end |
Instance Method Details
#audio? ⇒ true, false
Returns whether this file is an audio file.
100 101 102 |
# File 'lib/rubycord/data/attachment.rb', line 100 def audio? !@duration_secs.nil? end |
#ephemeral? ⇒ true, false
Returns whether this attachment is ephemeral.
105 106 107 |
# File 'lib/rubycord/data/attachment.rb', line 105 def ephemeral? @ephemeral end |
#image? ⇒ true, false
Returns whether this file is an image file.
95 96 97 |
# File 'lib/rubycord/data/attachment.rb', line 95 def image? !(@width.nil? || @height.nil?) end |