Method: IsoDoc::ClassUtils#case_strict

Defined in:
lib/isodoc/class_utils.rb

#case_strict(text, casing, script, firstonly: true) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/isodoc/class_utils.rb', line 28

def case_strict(text, casing, script, firstonly: true)
  return text unless %w(Latn Cyrl Grek Armn).include?(script)

  seen = false
  text.split(/(\s+)/).map do |w|
    letters = w.chars
    case_strict1(letters, casing) if !seen || !firstonly
    seen ||= /\S/.match?(w)
    letters.join
  end.join
end