Class: Discorb::Embed::Image

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

Overview

Represents an image of embed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Image

Initialize a new Image object.

Parameters:

  • url (String)

    URL of image.



287
288
289
290
291
292
293
294
295
296
297
# File 'lib/discorb/embed.rb', line 287

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

#heightInteger? (readonly)

Returns:

  • (Integer)

    The height of image.

  • (nil)

    The Image object wasn’t created from gateway.



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

def height
  @height
end

#proxy_urlString? (readonly)

Returns:

  • (String)

    The proxy url of image.

  • (nil)

    The Image object wasn’t created from gateway.



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

def proxy_url
  @proxy_url
end

#urlString

Returns The url of image.

Returns:

  • (String)

    The url of image.



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

def url
  @url
end

#widthInteger? (readonly)

Returns:

  • (Integer)

    The width of image.

  • (nil)

    The Image object wasn’t created from gateway.



280
281
282
# File 'lib/discorb/embed.rb', line 280

def width
  @width
end

Instance Method Details

#to_hashHash

Convert image to hash for sending.

Returns:

  • (Hash)

    Converted image.

See Also:



306
307
308
# File 'lib/discorb/embed.rb', line 306

def to_hash
  { url: @url }
end