Class: Discorb::UnicodeEmoji
Overview
Represents a unicode emoji (default emoji) in discord.
Instance Attribute Summary collapse
-
#name -> String
readonly
The name of the emoji.
-
#skin_tone -> Integer
readonly
The skin tone of the emoji.
-
#value -> String
readonly
The unicode value of the emoji.
Instance Method Summary collapse
-
#initialize(name, tone: 0) -> UnicodeEmoji
constructor
Initialize a new unicode emoji.
- #inspect -> Object
-
#to_s -> String
The unicode string of the emoji.
-
#to_uri -> String
Format the emoji for URI.
Methods inherited from Emoji
Constructor Details
#initialize(name, tone: 0) -> UnicodeEmoji
Initialize a new unicode emoji.
226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/discorb/emoji.rb', line 226 def initialize(name, tone: 0) if EmojiTable::DISCORD_TO_UNICODE.key?(name) @name = name @value = EmojiTable::DISCORD_TO_UNICODE[name] elsif EmojiTable::UNICODE_TO_DISCORD.key?(name) @name = EmojiTable::UNICODE_TO_DISCORD[name][0] @value = name else raise ArgumentError, "No such emoji: #{name}" end @value += EmojiTable::SKIN_TONES[tone] if tone.positive? end |
Instance Attribute Details
#name -> String (readonly)
Returns The name of the emoji. (e.g. :grinning:).
214 215 216 |
# File 'lib/discorb/emoji.rb', line 214 def name @name end |
#skin_tone -> Integer (readonly)
Returns The skin tone of the emoji.
218 219 220 |
# File 'lib/discorb/emoji.rb', line 218 def skin_tone @skin_tone end |
#value -> String (readonly)
Returns The unicode value of the emoji. (e.g. U+1F600).
216 217 218 |
# File 'lib/discorb/emoji.rb', line 216 def value @value end |
Instance Method Details
#inspect -> Object
253 254 255 |
# File 'lib/discorb/emoji.rb', line 253 def inspect "#<#{self.class} :#{@name}:>" end |
#to_s -> String
Returns The unicode string of the emoji.
240 241 242 |
# File 'lib/discorb/emoji.rb', line 240 def to_s @value end |
#to_uri -> String
Format the emoji for URI.
249 250 251 |
# File 'lib/discorb/emoji.rb', line 249 def to_uri URI.encode_www_form_component(@value) end |