Class: Discorb::Embed::Image

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



240
241
242
243
244
245
246
247
248
249
250
# File 'lib/discorb/embed.rb', line 240

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 image.

  • (nil)

    The Image object wasn't created from gateway.



230
231
232
# File 'lib/discorb/embed.rb', line 230

def height
  @height
end

#proxy_url -> String? (readonly)

Returns:

  • (String)

    The proxy url of image.

  • (nil)

    The Image object wasn't created from gateway.



227
228
229
# File 'lib/discorb/embed.rb', line 227

def proxy_url
  @proxy_url
end

#url -> String

Returns The url of image.

Returns:

  • (String)

    The url of image.



224
225
226
# File 'lib/discorb/embed.rb', line 224

def url
  @url
end

#width -> Integer? (readonly)

Returns:

  • (Integer)

    The width of image.

  • (nil)

    The Image object wasn't created from gateway.



233
234
235
# File 'lib/discorb/embed.rb', line 233

def width
  @width
end

Instance Method Details

#to_hash -> Hash

Convert image to hash for sending.

Returns:

  • (Hash)

    Converted image.

See Also:



258
259
260
# File 'lib/discorb/embed.rb', line 258

def to_hash
  { url: @url }
end