Class: Discorb::Embed::Thumbnail

Inherits:
Entry
  • 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.



326
327
328
329
330
331
332
333
334
335
336
# File 'lib/discorb/embed.rb', line 326

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.



316
317
318
# File 'lib/discorb/embed.rb', line 316

def height
  @height
end

#proxy_url -> String? (readonly)

Returns:

  • (String)

    The proxy url of thumbnail.

  • (nil)

    The Thumbnail object wasn't created from gateway.



313
314
315
# File 'lib/discorb/embed.rb', line 313

def proxy_url
  @proxy_url
end

#url -> String

Returns The url of thumbnail.

Returns:

  • (String)

    The url of thumbnail.



310
311
312
# File 'lib/discorb/embed.rb', line 310

def url
  @url
end

#width -> Integer? (readonly)

Returns:

  • (Integer)

    The width of thumbnail.

  • (nil)

    The Thumbnail object wasn't created from gateway.



319
320
321
# File 'lib/discorb/embed.rb', line 319

def width
  @width
end

Instance Method Details

#to_hash -> Hash

Convert thumbnail to hash for sending.

Returns:

  • (Hash)

    Converted thumbnail.

See Also:



345
346
347
# File 'lib/discorb/embed.rb', line 345

def to_hash
  { url: @url }
end