Module: Emoji
- Extended by:
- Emoji
- Included in:
- Emoji
- Defined in:
- lib/negarmoji/emoji.rb,
lib/negarmoji/version.rb,
lib/negarmoji/character.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Character
Constant Summary collapse
- VERSION =
"0.1.6"
Instance Method Summary collapse
- #all ⇒ Object
-
#create(name) ⇒ Object
Public: Initialize an Emoji::Character instance and yield it to the block.
- #data_file ⇒ Object
-
#edit_emoji(emoji) {|emoji| ... } ⇒ Object
Public: Yield an negarmoji to the block and update the indices in case its aliases or unicode_aliases lists changed.
-
#find_by_alias(name) ⇒ Object
Public: Find an negarmoji by its aliased name.
-
#find_by_unicode(unicode) ⇒ Object
Public: Find an negarmoji by its unicode character.
Instance Method Details
#all ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/negarmoji/emoji.rb', line 13 def all return @all if defined? @all @all = [] parse_data_file @all end |
#create(name) ⇒ Object
Public: Initialize an Emoji::Character instance and yield it to the block. The character is added to the ‘Emoji.all` set.
23 24 25 26 27 |
# File 'lib/negarmoji/emoji.rb', line 23 def create(name) emoji = Emoji::Character.new(name) all << edit_emoji(emoji) { yield emoji if block_given? } emoji end |
#data_file ⇒ Object
9 10 11 |
# File 'lib/negarmoji/emoji.rb', line 9 def data_file File.("../../db/negarmoji.json", __dir__) end |
#edit_emoji(emoji) {|emoji| ... } ⇒ Object
Public: Yield an negarmoji to the block and update the indices in case its aliases or unicode_aliases lists changed.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/negarmoji/emoji.rb', line 31 def edit_emoji(emoji) @names_index ||= {} @unicodes_index ||= {} yield emoji emoji.aliases.each do |name| @names_index[name] = emoji end emoji.unicode_aliases.each do |unicode| @unicodes_index[unicode] = emoji end emoji end |
#find_by_alias(name) ⇒ Object
Public: Find an negarmoji by its aliased name. Return nil if missing.
48 49 50 |
# File 'lib/negarmoji/emoji.rb', line 48 def find_by_alias(name) names_index[name] end |
#find_by_unicode(unicode) ⇒ Object
Public: Find an negarmoji by its unicode character. Return nil if missing.
53 54 55 |
# File 'lib/negarmoji/emoji.rb', line 53 def find_by_unicode(unicode) unicodes_index[unicode] end |