Module: Worldwide::Scripts
- Defined in:
- lib/worldwide/scripts.rb
Class Method Summary collapse
-
.identify(text:) ⇒ Object
Based off of the text provided, method will return the scripts identified.
Class Method Details
.identify(text:) ⇒ Object
Based off of the text provided, method will return the scripts identified
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/worldwide/scripts.rb', line 7 def identify(text:) return [] if text.blank? discovered_scripts = [] script_regexes = { "Latn": "[A-Za-z\uFF21-\uFF3A\uFF41-\uFF5A]", "Han": "\\p{Han}", "Katakana": "\\p{Katakana}", "Hiragana": "\\p{Hiragana}", } script_regexes.each do |script, regex| if text.match(regex) discovered_scripts.push(script) end end discovered_scripts end |