class String

Constants

RE_PARANTHESIZED

Regex stolen from stackoverflow.com/a/6331667

TURKISH_CHARS

Public Instance Methods

abbreviation() click to toggle source
# File lib/omu_support/core_ext/string.rb, line 40
def abbreviation
  split.map(&:first).join.upcase(:turkic)
end
affixed(**options) click to toggle source
# File lib/omu_support/core_ext/string.rb, line 36
def affixed(**options)
  [self].join_affixed(**options)
end
asciified() click to toggle source
# File lib/omu_support/core_ext/string.rb, line 32
def asciified
  chars.to_a.map { |char| (ascii = TURKISH_CHARS[char]) ? ascii : char }.join
end
capitalize_turkish() click to toggle source
# File lib/omu_support/core_ext/string.rb, line 44
def capitalize_turkish
  downcase(:turkic).split.map do |word|
    if word.inside_abbreviations? :tr
      word.upcase(:turkic)
    elsif word.inside_conjunctions? :tr
      word
    else
      word.capitalize(:turkic)
    end
  end.join(' ')
end
capitalize_turkish_with_parenthesized() click to toggle source
# File lib/omu_support/core_ext/string.rb, line 56
def capitalize_turkish_with_parenthesized
  capitalize_turkish.gsub RE_PARANTHESIZED do |match|
    "(#{match[1..-2].capitalize_turkish})"
  end
end