Class: Rubycord::Emoji

Inherits:
Object
  • Object
show all
Includes:
IDObject
Defined in:
lib/rubycord/data/emoji.rb

Overview

Server emoji

Instance Attribute Summary collapse

Attributes included from IDObject

#id

Instance Method Summary collapse

Methods included from IDObject

#creation_time, synthesise

Instance Attribute Details

#animatedtrue, false (readonly) Also known as: animated?



16
17
18
# File 'lib/rubycord/data/emoji.rb', line 16

def animated
  @animated
end

#nameString (readonly)



7
8
9
# File 'lib/rubycord/data/emoji.rb', line 7

def name
  @name
end

#rolesArray<Role>? (readonly)



13
14
15
# File 'lib/rubycord/data/emoji.rb', line 13

def roles
  @roles
end

#serverServer? (readonly)



10
11
12
# File 'lib/rubycord/data/emoji.rb', line 10

def server
  @server
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

ID or name based comparison



33
34
35
36
37
38
# File 'lib/rubycord/data/emoji.rb', line 33

def ==(other)
  return false unless other.is_a? Emoji
  return Rubycord.id_compare(@id, other) if @id

  name == other.name
end

#icon_urlString



60
61
62
# File 'lib/rubycord/data/emoji.rb', line 60

def icon_url
  API.emoji_icon_url(id)
end

#inspectObject

The inspect method is overwritten to give more useful output



65
66
67
# File 'lib/rubycord/data/emoji.rb', line 65

def inspect
  "<Emoji name=#{name} id=#{id} animated=#{animated}>"
end

#mentionString Also known as: use, to_s



43
44
45
46
47
# File 'lib/rubycord/data/emoji.rb', line 43

def mention
  return name if id.nil?

  "<#{"a" if animated}:#{name}:#{id}>"
end

#to_reactionString



53
54
55
56
57
# File 'lib/rubycord/data/emoji.rb', line 53

def to_reaction
  return name if id.nil?

  "#{name}:#{id}"
end