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
-
#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.
-
#url ⇒ String
readonly
The CDN URL this attachment can be downloaded at.
-
#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.
-
#spoiler? ⇒ true, false
Whether this file is tagged as a spoiler.
Methods included from IDObject
#==, #creation_time, synthesise
Instance Attribute Details
#filename ⇒ String (readonly)
Returns the attachment's filename.
19 20 21 |
# File 'lib/discordrb/data/attachment.rb', line 19 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.
28 29 30 |
# File 'lib/discordrb/data/attachment.rb', line 28 def height @height end |
#message ⇒ Message (readonly)
Returns the message this attachment belongs to.
9 10 11 |
# File 'lib/discordrb/data/attachment.rb', line 9 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.
16 17 18 |
# File 'lib/discordrb/data/attachment.rb', line 16 def proxy_url @proxy_url end |
#size ⇒ Integer (readonly)
Returns the attachment's file size in bytes.
22 23 24 |
# File 'lib/discordrb/data/attachment.rb', line 22 def size @size end |
#url ⇒ String (readonly)
Returns the CDN URL this attachment can be downloaded at.
12 13 14 |
# File 'lib/discordrb/data/attachment.rb', line 12 def url @url end |
#width ⇒ Integer? (readonly)
Returns the width 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 width @width end |
Instance Method Details
#image? ⇒ true, false
Returns whether this file is an image file.
47 48 49 |
# File 'lib/discordrb/data/attachment.rb', line 47 def image? !(@width.nil? || @height.nil?) end |
#spoiler? ⇒ true, false
Returns whether this file is tagged as a spoiler.
52 53 54 |
# File 'lib/discordrb/data/attachment.rb', line 52 def spoiler? @filename.start_with? 'SPOILER_' end |