Module: Sanscript
- Defined in:
- lib/sanscript.rb,
lib/sanscript/detect.rb,
lib/sanscript/version.rb,
lib/sanscript/benchmark.rb,
lib/sanscript/exceptions.rb,
lib/sanscript/detect/ruby24.rb,
lib/sanscript/detect/ruby2x.rb,
lib/sanscript/transliterate.rb,
lib/sanscript/transliterate/schemes.rb
Overview
Sanscript.rb detection/transliteration module for Sanskrit.
Defined Under Namespace
Modules: Benchmark, Detect, Transliterate Classes: DetectionError, SchemeNotSupportedError
Constant Summary collapse
- VERSION =
The version number
"0.6.2"
Class Method Summary collapse
-
.detect(text) ⇒ Symbol?
Attempts to detect the encoding scheme of the provided string.
-
.transliterate(text, from, to = nil, **opts) ⇒ Object
Transliterates a string, optionally detecting its source-scheme first.
Class Method Details
.detect(text) ⇒ Symbol?
Attempts to detect the encoding scheme of the provided string. Simple proxy for Sanscript::Detect.detect_scheme
19 20 21 |
# File 'lib/sanscript.rb', line 19 def detect(text) Detect.detect_scheme(text) end |
.transliterate(text, from, to, **opts) ⇒ String .transliterate(text, to, **opts) ⇒ String
Transliterates a string, optionally detecting its source-scheme first.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/sanscript.rb', line 48 def transliterate(text, from, to = nil, **opts) if to.nil? to = from from = nil end if from.nil? from = Detect.detect_scheme(text) || opts[:default_scheme] || raise(DetectionError, "String detection and fallback failed.") end Transliterate.transliterate(text, from, to, opts) end |