Class: Discordrb::Attachment

Inherits:
Object
  • Object
show all
Includes:
IDObject
Defined in:
lib/discordrb/data.rb

Overview

An attachment to a message

Instance Attribute Summary collapse

Attributes included from IDObject

#id

Instance Method Summary collapse

Methods included from IDObject

#==, #creation_time, synthesise

Instance Attribute Details

#filenameString (readonly)

Returns the attachment's filename.

Returns:

  • (String)

    the attachment's filename.


2079
2080
2081
# File 'lib/discordrb/data.rb', line 2079

def filename
  @filename
end

#heightInteger? (readonly)

Returns the height of an image file, in pixels, or nil if the file is not an image.

Returns:

  • (Integer, nil)

    the height of an image file, in pixels, or nil if the file is not an image.


2088
2089
2090
# File 'lib/discordrb/data.rb', line 2088

def height
  @height
end

#messageMessage (readonly)

Returns the message this attachment belongs to.

Returns:

  • (Message)

    the message this attachment belongs to.


2069
2070
2071
# File 'lib/discordrb/data.rb', line 2069

def message
  @message
end

#proxy_urlString (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.

Returns:

  • (String)

    the attachment's proxy URL - I'm not sure what exactly this does, but I think it has something to do with CDNs


2076
2077
2078
# File 'lib/discordrb/data.rb', line 2076

def proxy_url
  @proxy_url
end

#sizeInteger (readonly)

Returns the attachment's file size in bytes.

Returns:

  • (Integer)

    the attachment's file size in bytes.


2082
2083
2084
# File 'lib/discordrb/data.rb', line 2082

def size
  @size
end

#urlString (readonly)

Returns the CDN URL this attachment can be downloaded at.

Returns:

  • (String)

    the CDN URL this attachment can be downloaded at.


2072
2073
2074
# File 'lib/discordrb/data.rb', line 2072

def url
  @url
end

#widthInteger? (readonly)

Returns the width of an image file, in pixels, or nil if the file is not an image.

Returns:

  • (Integer, nil)

    the width of an image file, in pixels, or nil if the file is not an image.


2085
2086
2087
# File 'lib/discordrb/data.rb', line 2085

def width
  @width
end

Instance Method Details

#image?true, false

Returns whether this file is an image file.

Returns:

  • (true, false)

    whether this file is an image file.


2106
2107
2108
# File 'lib/discordrb/data.rb', line 2106

def image?
  !(@width.nil? || @height.nil?)
end