class Discorb::Attachment

Represents a attachment file.

Attributes

content_type[R]

@return [String] The attachment content type.

filename[R]

@return [String] The attachment filename.

height[R]

@return [Integer] The image height. @return [nil] If the attachment is not an image.

id[R]

@return [Discorb::Snowflake] The attachment id.

io[R]

@return [#read] The file content.

proxy_url[R]

@return [String] The attachment proxy url.

size[R]

@return [Integer] The attachment size in bytes.

url[R]

@return [String] The attachment url.

width[R]

@return [Integer] The image width. @return [nil] If the attachment is not an image.

Public Class Methods

new(data) click to toggle source

@!visibility private

# File lib/discorb/file.rb, line 35
def initialize(data)
  @id = Snowflake.new(data[:id])
  @filename = data[:filename]
  @content_type = data[:content_type]
  @size = data[:size]
  @url = data[:url]
  @proxy_url = data[:proxy_url]
  @height = data[:height]
  @width = data[:width]
end

Public Instance Methods

image?() click to toggle source
# File lib/discorb/file.rb, line 46
def image?
  @content_type.start_with? "image/"
end