summaryrefslogtreecommitdiff
path: root/lib/unicode_normalize
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-09 09:33:36 +0000
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-09 09:33:36 +0000
commit62b511b6aa9e2c1ceb11048f012eed13e5feabfb (patch)
treec96c8476c5a06b16bc9f1f7bc7b39e7d5f55372e /lib/unicode_normalize
parentb30ff6839db848efafc4b7b61abed0e2708d2627 (diff)
lib/unicode_normalize/normalize.rb: Replaced if-else by case in self.normalized? in parallel to r48309.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/unicode_normalize')
-rw-r--r--lib/unicode_normalize/normalize.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/unicode_normalize/normalize.rb b/lib/unicode_normalize/normalize.rb
index 5fea8c5..86e83f2 100644
--- a/lib/unicode_normalize/normalize.rb
+++ b/lib/unicode_normalize/normalize.rb
@@ -136,7 +136,8 @@ module UnicodeNormalize
def self.normalized?(string, form = :nfc)
encoding = string.encoding
- if encoding == Encoding::UTF_8
+ case encoding
+ when Encoding::UTF_8
case form
when :nfc then
string.scan REGEXP_C do |match|
@@ -155,9 +156,9 @@ module UnicodeNormalize
else
raise ArgumentError, "Invalid normalization form #{form}."
end
- elsif encoding == Encoding::US_ASCII
+ when Encoding::US_ASCII
true
- elsif UNICODE_ENCODINGS.include? encoding
+ when **UNICODE_ENCODINGS
normalized? string.encode(Encoding::UTF_8), form
else
raise Encoding::CompatibilityError, "Unicode Normalization not appropriate for #{encoding}"