module Gemojione
Constants
- VERSION
Public Class Methods
asset_host()
click to toggle source
# File lib/gemojione.rb, line 20 def self.asset_host @asset_host || 'http://localhost:3000' end
asset_host=(host)
click to toggle source
# File lib/gemojione.rb, line 24 def self.asset_host=(host) @asset_host = host end
asset_path()
click to toggle source
# File lib/gemojione.rb, line 28 def self.asset_path @asset_path || '/' end
asset_path=(path)
click to toggle source
# File lib/gemojione.rb, line 32 def self.asset_path=(path) @asset_path = path end
escape_html(string)
click to toggle source
# File lib/gemojione.rb, line 69 def self.escape_html(string) @escaper.escape_html(string) end
image_url_for_name(name)
click to toggle source
# File lib/gemojione.rb, line 36 def self.image_url_for_name(name) emoji = index.find_by_name(name) "#{asset_host}#{ File.join(asset_path, emoji['unicode']) }.png" end
image_url_for_unicode_moji(moji)
click to toggle source
# File lib/gemojione.rb, line 41 def self.image_url_for_unicode_moji(moji) emoji = index.find_by_moji(moji) image_url_for_name(emoji['name']) end
index()
click to toggle source
# File lib/gemojione.rb, line 73 def self.index @index ||= Index.new end
replace_unicode_moji_with_images(string)
click to toggle source
# File lib/gemojione.rb, line 46 def self.replace_unicode_moji_with_images(string) return string unless string unless string.match(index.unicode_moji_regex) return safe_string(string) end safe_string = safe_string(string.dup) safe_string.gsub!(index.unicode_moji_regex) do |moji| %Q{<img alt="#{moji}" class="emoji" src="#{ image_url_for_unicode_moji(moji) }">} end safe_string = safe_string.html_safe if safe_string.respond_to?(:html_safe) safe_string end
safe_string(string)
click to toggle source
# File lib/gemojione.rb, line 61 def self.safe_string(string) if string.respond_to?(:html_safe?) && string.html_safe? string else escape_html(string) end end