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 27 28 29 |
# File 'lib/worldwide/scripts.rb', line 7 def identify(text:) return [] if Util.blank?(text) discovered_scripts = [] script_regexes = { "Arabic": "\\p{Arabic}", "Han": "\\p{Han}", "Hangul": "\\p{Hangul}", "Hiragana": "\\p{Hiragana}", "Katakana": "\\p{Katakana}", "Latin": "\\p{Latin}", "Thai": "\\p{Thai}", } script_regexes.each do |script, regex| if text.match(regex) discovered_scripts.push(script) end end discovered_scripts end |