Class: Discorb::Asset
- Inherits:
-
DiscordModel
- Object
- DiscordModel
- Discorb::Asset
- Defined in:
- lib/discorb/asset.rb
Overview
Represents a single asset.
Instance Attribute Summary collapse
-
#animated? ⇒ Boolean
readonly
Whether the asset is animated.
-
#hash ⇒ String
readonly
The hash of asset.
Instance Method Summary collapse
- #inspect ⇒ Object
-
#url(image_format: nil, size: 1024) ⇒ String
URL of the asset.
Methods inherited from DiscordModel
Instance Attribute Details
#animated? ⇒ Boolean (readonly)
Returns Whether the asset is animated.
|
# File 'lib/discorb/asset.rb', line 11
|
#hash ⇒ String (readonly)
Returns The hash of asset.
9 10 11 |
# File 'lib/discorb/asset.rb', line 9 def hash @hash end |
Instance Method Details
#inspect ⇒ Object
44 45 46 |
# File 'lib/discorb/asset.rb', line 44 def inspect "#<#{self.class} #{@target.class} #{@hash}>" end |
#url(image_format: nil, size: 1024) ⇒ String
URL of the asset.
39 40 41 42 |
# File 'lib/discorb/asset.rb', line 39 def url(image_format: nil, size: 1024) path = @path || "#{endpoint}/#{@target.id}" "https://cdn.discordapp.com/#{path}/#{@hash}.#{image_format or (animated? ? "gif" : "webp")}?size=#{size}" end |