Class: Rubord::Emoji
- Inherits:
-
Object
- Object
- Rubord::Emoji
- Defined in:
- lib/rubord/models/emoji.rb
Instance Attribute Summary collapse
-
#animated ⇒ Object
readonly
Returns the value of attribute animated.
-
#available ⇒ Object
readonly
Returns the value of attribute available.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#managed ⇒ Object
readonly
Returns the value of attribute managed.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#require_colons ⇒ Object
readonly
Returns the value of attribute require_colons.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(data, client) ⇒ Emoji
constructor
A new instance of Emoji.
- #inspect ⇒ Object
- #to_discord ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(data, client) ⇒ Emoji
Returns a new instance of Emoji.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rubord/models/emoji.rb', line 12 def initialize(data, client) @client = client @id = data["id"] @name = data["name"] @roles = data["roles"] || [] @require_colons = data["require_colons"] @managed = data["managed"] @animated = data["animated"] @available = data.fetch("available", true) if data["user"] @user = Rubord::User.new(data["user"]) client.users.set(@user.id, @user) end end |
Instance Attribute Details
#animated ⇒ Object (readonly)
Returns the value of attribute animated.
3 4 5 |
# File 'lib/rubord/models/emoji.rb', line 3 def animated @animated end |
#available ⇒ Object (readonly)
Returns the value of attribute available.
3 4 5 |
# File 'lib/rubord/models/emoji.rb', line 3 def available @available end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/rubord/models/emoji.rb', line 3 def id @id end |
#managed ⇒ Object (readonly)
Returns the value of attribute managed.
3 4 5 |
# File 'lib/rubord/models/emoji.rb', line 3 def managed @managed end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rubord/models/emoji.rb', line 3 def name @name end |
#require_colons ⇒ Object (readonly)
Returns the value of attribute require_colons.
3 4 5 |
# File 'lib/rubord/models/emoji.rb', line 3 def require_colons @require_colons end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
3 4 5 |
# File 'lib/rubord/models/emoji.rb', line 3 def roles @roles end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'lib/rubord/models/emoji.rb', line 3 def user @user end |
Instance Method Details
#inspect ⇒ Object
50 51 52 |
# File 'lib/rubord/models/emoji.rb', line 50 def inspect "#<Rubord::Emoji name=#{@name} id=#{@id}" end |
#to_discord ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/rubord/models/emoji.rb', line 28 def to_discord if animated "<a:#{@name}:#{@id}>" else "<:#{@name}:#{@id}>" end end |
#to_h ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rubord/models/emoji.rb', line 36 def to_h { id: @id, name: @name, roles: @roles, format: to_discord, user: @user ? @user.to_h : nil, require_colons: @require_colons, managed: @managed, animated: @animated, available: @available } end |