Class: IndexImporter

Inherits:
Object
  • Object
show all
Defined in:
lib/gemojione/index_importer.rb

Constant Summary collapse

SOURCE =
'https://raw.githubusercontent.com/joypixels/emojione/master/emoji.json'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.import_from_emojioneObject



4
5
6
# File 'lib/gemojione/index_importer.rb', line 4

def self.import_from_emojione
  new.import_from_emojione
end

Instance Method Details

#import_from_emojioneObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gemojione/index_importer.rb', line 8

def import_from_emojione
  count = 0

  mojis.each do |array|
    unicode = array[0].upcase
    hash = array[1]

    unless index.find_by_unicode(unicode)
      count += 1
      add_moji(
        hash['shortname'].gsub(':', ''),
        unicode,
        hash['name'],
        hash['category'],
        hash['code_points']['fully_qualified'].split('-').map { |u| u.downcase.to_i(16) }.pack('U*'),
        hash['shortname_alternates']
      )
    end
  end

  puts "Added #{count} emojis to the index"
end