Class: Hobostove::Emoji

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

Class Method Summary collapse

Class Method Details

.replace(string) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/hobostove/emoji.rb', line 5

def self.replace(string)
  csv = File.expand_path("../../../data/emoji.csv", __FILE__)
  CSV.foreach(csv) do |row|
    if string =~ /:#{row[0]}:/
      character = [row[1].hex].pack("U")
      string.gsub!(":#{row[0]}:", character)
    end
  end

  string
end