Module: Sanscript::Detect::Ruby2x
- Included in:
- Sanscript::Detect
- Defined in:
- lib/sanscript/detect/ruby2x.rb
Overview
Module implementing ‘detect_scheme` method using Ruby 2.x-compatible syntax. (Note: This module will only load if chosen by Sanscript::Detect.)
Instance Method Summary collapse
-
#ruby_detect_scheme(text) ⇒ Symbol?
Attempts to detect the encoding scheme of the provided string.
Instance Method Details
#ruby_detect_scheme(text) ⇒ Symbol?
Attempts to detect the encoding scheme of the provided string.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sanscript/detect/ruby2x.rb', line 12 def ruby_detect_scheme(text) text = text.to_str.gsub(RE_CONTROL_BLOCK, "") # rubocop:disable Style/CaseEquality # Brahmic schemes are all within a specific range of code points. if RE_BRAHMIC_RANGE === text RE_BRAHMIC_SCRIPTS.each do |script, regex| return script if regex === text end end # Romanizations if RE_IAST_OR_KOLKATA_ONLY === text return :kolkata if RE_KOLKATA_ONLY === text :iast elsif RE_ITRANS_ONLY === text :itrans elsif RE_SLP1_ONLY === text :slp1 elsif RE_VELTHUIS_ONLY === text :velthuis elsif RE_ITRANS_OR_VELTHUIS_ONLY === text :itrans elsif RE_HARVARD_KYOTO === text :hk end end |