Class: RubyCord::User::Avatar
- Inherits:
-
Object
- Object
- RubyCord::User::Avatar
- Defined in:
- lib/rubycord/user/avatar.rb
Overview
Represents a single asset.
Instance Attribute Summary collapse
-
#animated? ⇒ Boolean
readonly
return [Boolean].
-
#hash ⇒ String?
readonly
The hash of asset.
Instance Method Summary collapse
-
#default? ⇒ Boolean
If this user has a default avatar.
-
#inspect ⇒ String
Object class and attributes.
-
#url(image_format: nil, size: 1024) ⇒ String
URL of the asset.
Instance Attribute Details
#animated? ⇒ Boolean (readonly)
return [Boolean]
|
# File 'lib/rubycord/user/avatar.rb', line 11
|
#hash ⇒ String? (readonly)
Returns The hash of asset.
9 10 11 |
# File 'lib/rubycord/user/avatar.rb', line 9 def hash @hash end |
Instance Method Details
#default? ⇒ Boolean
Returns If this user has a default avatar.
29 30 31 |
# File 'lib/rubycord/user/avatar.rb', line 29 def default? @hash.nil? end |
#inspect ⇒ String
Returns Object class and attributes.
57 58 59 |
# File 'lib/rubycord/user/avatar.rb', line 57 def inspect "#<#{self.class} #{@target.class} #{@hash}>" end |
#url(image_format: nil, size: 1024) ⇒ String
URL of the asset.
48 49 50 51 52 53 54 |
# File 'lib/rubycord/user/avatar.rb', line 48 def url(image_format: nil, size: 1024) if default? "https://cdn.discordapp.com/embed/avatars/#{@discriminator.to_i % 5}.png" else "https://cdn.discordapp.com/avatars/#{@id}/#{@hash}.#{image_format or (animated? ? "gif" : "webp")}?size=#{size}" end end |