Class: Discorb::Embed::Thumbnail

Inherits:
Object
  • Object
show all
Defined in:
lib/discorb/embed.rb

Overview

Represents a thumbnail of embed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) -> Thumbnail

Initialize a new Thumbnail object.

Parameters:

  • url (String)

    URL of thumbnail.



284
285
286
287
288
289
290
291
292
293
294
# File 'lib/discorb/embed.rb', line 284

def initialize(url)
  data = url
  if data.is_a? String
    @url = data
  else
    @url = data[:url]
    @proxy_url = data[:proxy_url]
    @height = data[:height]
    @width = data[:width]
  end
end

Instance Attribute Details

#height -> Integer? (readonly)

Returns:

  • (Integer)

    The height of thumbnail.

  • (nil)

    The Thumbnail object wasn't created from gateway.



274
275
276
# File 'lib/discorb/embed.rb', line 274

def height
  @height
end

#proxy_url -> String? (readonly)

Returns:

  • (String)

    The proxy url of thumbnail.

  • (nil)

    The Thumbnail object wasn't created from gateway.



271
272
273
# File 'lib/discorb/embed.rb', line 271

def proxy_url
  @proxy_url
end

#url -> String

Returns The url of thumbnail.

Returns:

  • (String)

    The url of thumbnail.



268
269
270
# File 'lib/discorb/embed.rb', line 268

def url
  @url
end

#width -> Integer? (readonly)

Returns:

  • (Integer)

    The width of thumbnail.

  • (nil)

    The Thumbnail object wasn't created from gateway.



277
278
279
# File 'lib/discorb/embed.rb', line 277

def width
  @width
end

Instance Method Details

#to_hash -> Hash

Convert thumbnail to hash for sending.

Returns:

  • (Hash)

    Converted thumbnail.

See Also:



302
303
304
# File 'lib/discorb/embed.rb', line 302

def to_hash
  { url: @url }
end