From cac15643cf5c62dddf672bfaf239b42c1e108d19 Mon Sep 17 00:00:00 2001 From: Norman Clarke Date: Fri, 6 Jan 2012 12:06:26 -0300 Subject: Implement Chars#swapcase. --- activesupport/lib/active_support/multibyte/unicode.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activesupport/lib/active_support/multibyte/unicode.rb') diff --git a/activesupport/lib/active_support/multibyte/unicode.rb b/activesupport/lib/active_support/multibyte/unicode.rb index 94fb0a48aa..a0a8f3c97e 100644 --- a/activesupport/lib/active_support/multibyte/unicode.rb +++ b/activesupport/lib/active_support/multibyte/unicode.rb @@ -293,9 +293,17 @@ module ActiveSupport apply_mapping string, :uppercase_mapping end + def swapcase(string) + apply_mapping string, :swapcase_mapping + end + # Holds data about a codepoint in the Unicode database class Codepoint attr_accessor :code, :combining_class, :decomp_type, :decomp_mapping, :uppercase_mapping, :lowercase_mapping + + def swapcase_mapping + uppercase_mapping > 0 ? uppercase_mapping : lowercase_mapping + end end # Holds static data from the Unicode database -- cgit v1.2.3