Class: EmojiExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/emoji-extractor.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ EmojiExtractor

Returns a new instance of EmojiExtractor.



4
5
6
# File 'lib/emoji-extractor.rb', line 4

def initialize(options)
  @options = options
end

Instance Method Details

#runObject



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

def run
  if File.directory?(@options[:dst])
    Dir.rmdir(@options[:dst])
  end
  FileUtils.mkdir_p @options[:dst]

  raise "Can't locate emoji ttf" unless File.exists?(@options[:file])
  ttf = File.new(@options[:file],"rb")
  ttf_data = ttf.read

  pos = 0
  while m = /\211PNG/.match(ttf_data[pos..-1])
    raise "no PNG found" if !m
    pos += m.begin(0) + 1
    ttf.seek(pos-1)

    extract_png(ttf)
  end

end