Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_extended/string.rb
Constant Summary collapse
- ACCENTS_MAPPING =
[ {letter: 'A', upcase: 'ÁÀÄÂ', downcase: 'áàäâ'}, {letter: 'E', upcase: 'ÉÈËÊ', downcase: 'éèëê'}, {letter: 'I', upcase: 'ÍÌÏÎ', downcase: 'íìïî'}, {letter: 'O', upcase: 'ÓÒÖÔ', downcase: 'óòöô'}, {letter: 'U', upcase: 'ÚÙÜÛ', downcase: 'úùüû'} ]
Instance Method Summary collapse
- #downcase ⇒ Object
- #downcase! ⇒ Object
- #downcase_ignoring_accents! ⇒ Object
- #normalized ⇒ Object
- #normalized! ⇒ Object
- #unaccented ⇒ Object
- #unaccented! ⇒ Object
- #upcase ⇒ Object
- #upcase! ⇒ Object
- #upcase_ignoring_accents! ⇒ Object
Instance Method Details
#downcase ⇒ Object
28 29 30 |
# File 'lib/core_extended/string.rb', line 28 def downcase self.dup.downcase! end |
#downcase! ⇒ Object
23 24 25 26 |
# File 'lib/core_extended/string.rb', line 23 def downcase! ACCENTS_MAPPING.each { |map| tr! map[:upcase], map[:downcase] } downcase_ignoring_accents! || self end |
#downcase_ignoring_accents! ⇒ Object
22 |
# File 'lib/core_extended/string.rb', line 22 alias_method :downcase_ignoring_accents!, :downcase! |
#normalized ⇒ Object
48 49 50 |
# File 'lib/core_extended/string.rb', line 48 def normalized self.dup.normalized! end |
#normalized! ⇒ Object
44 45 46 |
# File 'lib/core_extended/string.rb', line 44 def normalized! self.unaccented!.downcase! end |
#unaccented ⇒ Object
40 41 42 |
# File 'lib/core_extended/string.rb', line 40 def unaccented self.dup.unaccented! end |
#unaccented! ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/core_extended/string.rb', line 32 def unaccented! ACCENTS_MAPPING.each do |map| tr! map[:upcase], map[:letter] tr! map[:downcase], map[:letter].downcase end self end |
#upcase ⇒ Object
18 19 20 |
# File 'lib/core_extended/string.rb', line 18 def upcase self.dup.upcase! end |
#upcase! ⇒ Object
13 14 15 16 |
# File 'lib/core_extended/string.rb', line 13 def upcase! ACCENTS_MAPPING.each { |map| tr! map[:downcase], map[:upcase] } upcase_ignoring_accents! || self end |
#upcase_ignoring_accents! ⇒ Object
12 |
# File 'lib/core_extended/string.rb', line 12 alias_method :upcase_ignoring_accents!, :upcase! |