Sha256: 5b1033e09a8e30677aac1b293b5cd1b64cce8273e88345e455f4feed486fa452
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
# encoding: utf-8 class String ACCENTS_MAPPING = [ {letter: 'A', upcase: 'ÁÀÄÂ', downcase: 'áàäâ'}, {letter: 'E', upcase: 'ÉÈËÊ', downcase: 'éèëê'}, {letter: 'I', upcase: 'ÍÌÏÎ', downcase: 'íìïî'}, {letter: 'O', upcase: 'ÓÒÖÔ', downcase: 'óòöô'}, {letter: 'U', upcase: 'ÚÙÜÛ', downcase: 'úùüû'} ] alias_method :upcase_ignoring_accents!, :upcase! def upcase! ACCENTS_MAPPING.each { |map| tr! map[:downcase], map[:upcase] } upcase_ignoring_accents! || self end def upcase self.dup.upcase! end alias_method :downcase_ignoring_accents!, :downcase! def downcase! ACCENTS_MAPPING.each { |map| tr! map[:upcase], map[:downcase] } downcase_ignoring_accents! || self end def downcase self.dup.downcase! end def unaccented! ACCENTS_MAPPING.each do |map| tr! map[:upcase], map[:letter] tr! map[:downcase], map[:letter].downcase end self end def unaccented self.dup.unaccented! end def normalized! self.unaccented!.downcase! end def normalized self.dup.normalized! end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
core_extended-0.0.2 | lib/core_extended/string.rb |