mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
save a few method calls
This commit is contained in:
parent
cc12047372
commit
a3f96f16f4
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue