Class: Discordrb::Components::MediaItem

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/data/component.rb

Overview

Resolved metadata about a piece of media.

Constant Summary collapse

FLAGS =

Mapping of flags.

{
  animated: 1 << 0
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attachment_idInteger? (readonly)

Returns the ID of the uploaded attachment. Only present when the media item was uploaded via an attachment://<filename> reference.

Returns:

  • (Integer, nil)

    the ID of the uploaded attachment. Only present when the media item was uploaded via an attachment://<filename> reference.



477
478
479
# File 'lib/discordrb/data/component.rb', line 477

def attachment_id
  @attachment_id
end

#content_typeString? (readonly)

Returns the content type of the media item.

Returns:

  • (String, nil)

    the content type of the media item.



473
474
475
# File 'lib/discordrb/data/component.rb', line 473

def content_type
  @content_type
end

#flagsInteger (readonly)

Returns the flags of the media item.

Returns:

  • (Integer)

    the flags of the media item.



458
459
460
# File 'lib/discordrb/data/component.rb', line 458

def flags
  @flags
end

#heightInteger? (readonly)

Returns the height of the media item.

Returns:

  • (Integer, nil)

    the height of the media item.



464
465
466
# File 'lib/discordrb/data/component.rb', line 464

def height
  @height
end

#placeholderString? (readonly)

Returns the placeholder of the media item.

Returns:

  • (String, nil)

    the placeholder of the media item.



470
471
472
# File 'lib/discordrb/data/component.rb', line 470

def placeholder
  @placeholder
end

#placeholder_versionInteger? (readonly)

Returns the version of the thumbhash for images and videos, if any.

Returns:

  • (Integer, nil)

    the version of the thumbhash for images and videos, if any.



480
481
482
# File 'lib/discordrb/data/component.rb', line 480

def placeholder_version
  @placeholder_version
end

#proxy_urlString? (readonly)

Returns the proxied URL to the media item.

Returns:

  • (String, nil)

    the proxied URL to the media item.



467
468
469
# File 'lib/discordrb/data/component.rb', line 467

def proxy_url
  @proxy_url
end

#urlString (readonly)

Returns the URL to the media item.

Returns:

  • (String)

    the URL to the media item.



455
456
457
# File 'lib/discordrb/data/component.rb', line 455

def url
  @url
end

#widthInteger? (readonly)

Returns the width of the media item.

Returns:

  • (Integer, nil)

    the width of the media item.



461
462
463
# File 'lib/discordrb/data/component.rb', line 461

def width
  @width
end

Instance Method Details

#animated?true, false

Returns whether or not the media item is animated.

Returns:

  • (true, false)

    whether or not the media item is animated.



498
499
500
501
502
# File 'lib/discordrb/data/component.rb', line 498

FLAGS.each do |name, value|
  define_method("#{name}?") do
    @flags.anybits?(value)
  end
end