class EmojiDatasource::ShortNameToChar
Attributes
short_name[R]
Public Class Methods
generate(name)
click to toggle source
# File lib/emoji_datasource/short_name_to_char.rb, line 5 def self.generate(name) new(name).call end
new(short_name)
click to toggle source
# File lib/emoji_datasource/short_name_to_char.rb, line 11 def initialize(short_name) @short_name = short_name end
Public Instance Methods
call()
click to toggle source
# File lib/emoji_datasource/short_name_to_char.rb, line 15 def call return unless short_name return EmojiDatasource.find_by_short_name(short_name)&.to_char unless skin_tone_matches emoji = EmojiDatasource.find_by_short_name(skin_tone_matches[1]) return unless emoji return emoji.to_char if skin_tone_level == 1 char_with_skin_tone(emoji) end
Private Instance Methods
char_with_skin_tone(emoji)
click to toggle source
# File lib/emoji_datasource/short_name_to_char.rb, line 28 def char_with_skin_tone(emoji) return unless skin_tone_emoji skin_variation = emoji.skin_variations && emoji.skin_variations[skin_tone_emoji.unified] return unless skin_variation EmojiDatasource.unified_to_char(skin_variation[:unified]) end
skin_tone_emoji()
click to toggle source
# File lib/emoji_datasource/short_name_to_char.rb, line 37 def skin_tone_emoji EmojiDatasource.find_by_short_name("skin-tone-#{skin_tone_level}") end
skin_tone_level()
click to toggle source
# File lib/emoji_datasource/short_name_to_char.rb, line 41 def skin_tone_level skin_tone_matches[2].to_i end
skin_tone_matches()
click to toggle source
# File lib/emoji_datasource/short_name_to_char.rb, line 45 def skin_tone_matches short_name.match(/:?(.+)::skin-tone-(\d+):?/) end