Sha256: 9b6504e5065dd93b94f37a5a6aee671d600e9a593e88184b9e9c17587a4f0214
Contents?: true
Size: 663 Bytes
Versions: 5
Compression:
Stored size: 663 Bytes
Contents
# frozen_string_literal: true module Worldwide module Scripts class << self # Based off of the text provided, method will return the scripts identified 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 end end end
Version data entries
5 entries across 5 versions & 1 rubygems