diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-22 17:31:28 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-22 17:31:28 -0700 |
commit | a3f96f16f48dcdb8364d941f760c159ee136d36e (patch) | |
tree | dd60743e021ecb79e843bcc7879e4bf3668dbfd4 /activesupport/lib/active_support/multibyte/chars.rb | |
parent | cc120473727f285867300ce8637e6e7b54b93e02 (diff) | |
download | rails-a3f96f16f48dcdb8364d941f760c159ee136d36e.tar.gz rails-a3f96f16f48dcdb8364d941f760c159ee136d36e.tar.bz2 rails-a3f96f16f48dcdb8364d941f760c159ee136d36e.zip |
save a few method calls
Diffstat (limited to 'activesupport/lib/active_support/multibyte/chars.rb')
-rw-r--r-- | activesupport/lib/active_support/multibyte/chars.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index 0820579bec..f9607f1aaf 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -270,13 +270,14 @@ module ActiveSupport #:nodoc: @wrapped_string[*args] = replace_by else result = Unicode.u_unpack(@wrapped_string) - if args[0].is_a?(Fixnum) + case args.first + when Fixnum raise IndexError, "index #{args[0]} out of string" if args[0] >= result.length min = args[0] max = args[1].nil? ? min : (min + args[1] - 1) range = Range.new(min, max) replace_by = [replace_by].pack('U') if replace_by.is_a?(Fixnum) - elsif args.first.is_a?(Range) + when Range raise RangeError, "#{args[0]} out of range" if args[0].min >= result.length range = args[0] else |