emoji2020 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/emoji2020.rb +34 -4
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e7c097ecb7b075dcf76d48d18b248d0f403e51aaec053f3347d21a811b43b43
|
4
|
+
data.tar.gz: 0b563ddff60006ffeac7a8048968e58e1a2607b7edcd06487457de026e841ca7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adb686bb39adb1f6705ff9b94b2adec7a42f051012a6ab62ac8ffe4c96ca67ee5d6a2596fd141014a2c79d909e355dded5fd0b9d8f4e88f8c7a0d12ae4f7cc53
|
7
|
+
data.tar.gz: def9385b7be172922c435ae27f549a7f95a4ab8c634aada0ba3884485f0b7db6b89fcdad1ce3f528e3a256cae960538c7331d384580c669366ea197ce00b53e4
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/emoji2020.rb
CHANGED
@@ -563,7 +563,7 @@ EMOJI = "
|
|
563
563
|
🕸 Spider Web
|
564
564
|
🦂 Scorpion
|
565
565
|
🦟 Mosquito
|
566
|
-
🦠 Microbe
|
566
|
+
🦠 Microbe #virus
|
567
567
|
💐 Bouquet
|
568
568
|
🌸 Cherry Blossom
|
569
569
|
💮 White Flower
|
@@ -1776,16 +1776,19 @@ EMOJI = "
|
|
1776
1776
|
|
1777
1777
|
class Emoji2020
|
1778
1778
|
|
1779
|
-
def initialize(obj, debug: false)
|
1779
|
+
def initialize(obj=nil, debug: false)
|
1780
1780
|
|
1781
|
-
a = EMOJI.strip.gsub(
|
1781
|
+
a = EMOJI.strip.gsub(/\s+#[^\n]+/,'').gsub(/^\n/,'').lines\
|
1782
1782
|
.map {|x| x.chomp.lstrip.split(/ /,2).reverse}
|
1783
1783
|
h = a.map {|key, value| [key.downcase.gsub(/\W+/,'_').to_sym, value]}.to_h
|
1784
1784
|
puts 'h: ' + h.inspect if debug
|
1785
1785
|
|
1786
1786
|
@s = case obj.class.to_s
|
1787
1787
|
when 'Symbol'
|
1788
|
-
|
1788
|
+
|
1789
|
+
keyword = obj
|
1790
|
+
r = h[keyword]
|
1791
|
+
r ? r : h[find(keyword)]
|
1789
1792
|
|
1790
1793
|
when 'String'
|
1791
1794
|
|
@@ -1806,15 +1809,42 @@ class Emoji2020
|
|
1806
1809
|
end
|
1807
1810
|
|
1808
1811
|
end
|
1812
|
+
|
1813
|
+
# accepts a search keyword and returns the markdown name of the emoji
|
1814
|
+
# e.g. find('sunrise') #=> :sunrise:
|
1815
|
+
#
|
1816
|
+
def find(keyword)
|
1817
|
+
|
1818
|
+
r = search(keyword.to_s)
|
1819
|
+
return unless r
|
1820
|
+
|
1821
|
+
line = r.first
|
1822
|
+
_, title = line.strip.gsub(/\s+#[^\n]+/,'').split(/ /,2)
|
1823
|
+
title.downcase.gsub(/\W+/,'_').to_sym
|
1824
|
+
|
1825
|
+
end
|
1826
|
+
|
1827
|
+
# accepts a search keyword and returns a raw listing of emoji search results
|
1828
|
+
#
|
1829
|
+
def search(keyword)
|
1830
|
+
EMOJI.lines.grep /#{keyword}/i
|
1831
|
+
end
|
1809
1832
|
|
1833
|
+
# returns decimal value of each Unicode byte sequence used to
|
1834
|
+
# construct the emoji
|
1835
|
+
#
|
1810
1836
|
def to_a()
|
1811
1837
|
@s.unpack('U*')
|
1812
1838
|
end
|
1813
1839
|
|
1840
|
+
# returns the emoji
|
1841
|
+
#
|
1814
1842
|
def to_s()
|
1815
1843
|
@s
|
1816
1844
|
end
|
1817
1845
|
|
1846
|
+
# returns the Unicode value of the current emoji
|
1847
|
+
#
|
1818
1848
|
def to_unicode()
|
1819
1849
|
"U+{%s}" % self.to_a.map {|x| x.to_s(16)}.join(' ')
|
1820
1850
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|