Class: Plugin::CustomEmoji

Inherits:
Object
  • Object
show all
Defined in:
lib/plugin/instance.rb

Class Method Summary collapse

Class Method Details

.cache_keyObject



10
11
12
# File 'lib/plugin/instance.rb', line 10

def self.cache_key
  @@cache_key ||= CACHE_KEY
end

.clear_cacheObject



18
19
20
21
22
# File 'lib/plugin/instance.rb', line 18

def self.clear_cache
  @@cache_key = CACHE_KEY
  @@emojis = {}
  @@translations = {}
end

.emojisObject



14
15
16
# File 'lib/plugin/instance.rb', line 14

def self.emojis
  @@emojis ||= {}
end

.register(name, url, group = Emoji::DEFAULT_GROUP) ⇒ Object



24
25
26
27
28
29
# File 'lib/plugin/instance.rb', line 24

def self.register(name, url, group = Emoji::DEFAULT_GROUP)
  @@cache_key = Digest::SHA1.hexdigest(cache_key + name + group)[0..10]
  new_group = emojis[group] || {}
  new_group[name] = url
  emojis[group] = new_group
end

.translate(from, to) ⇒ Object



39
40
41
42
# File 'lib/plugin/instance.rb', line 39

def self.translate(from, to)
  @@cache_key = Digest::SHA1.hexdigest(cache_key + from)[0..10]
  translations[from] = to
end

.translationsObject



35
36
37
# File 'lib/plugin/instance.rb', line 35

def self.translations
  @@translations ||= {}
end

.unregister(name, group = Emoji::DEFAULT_GROUP) ⇒ Object



31
32
33
# File 'lib/plugin/instance.rb', line 31

def self.unregister(name, group = Emoji::DEFAULT_GROUP)
  emojis[group].delete(name)
end