aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/multibyte
diff options
context:
space:
mode:
authorNorman Clarke <norman@njclarke.com>2012-01-05 11:39:45 -0300
committerNorman Clarke <norman@njclarke.com>2012-01-05 11:39:45 -0300
commit5fb5ced0cba3306e0f39e45eb299fd0ea32cdd4b (patch)
tree31f0ba0646f2eadec39d1f7e552f580c8ad016c2 /activesupport/lib/active_support/multibyte
parent963c36004cfbe6c041460bab9c05718fc3bd7b58 (diff)
downloadrails-5fb5ced0cba3306e0f39e45eb299fd0ea32cdd4b.tar.gz
rails-5fb5ced0cba3306e0f39e45eb299fd0ea32cdd4b.tar.bz2
rails-5fb5ced0cba3306e0f39e45eb299fd0ea32cdd4b.zip
Remove overidden slice and slice! methods.
Diffstat (limited to 'activesupport/lib/active_support/multibyte')
-rw-r--r--activesupport/lib/active_support/multibyte/chars.rb30
1 files changed, 1 insertions, 29 deletions
diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb
index dcc176e93f..266cfc2eda 100644
--- a/activesupport/lib/active_support/multibyte/chars.rb
+++ b/activesupport/lib/active_support/multibyte/chars.rb
@@ -150,34 +150,6 @@ module ActiveSupport #:nodoc:
chars(Unicode.g_unpack(@wrapped_string).reverse.flatten.pack('U*'))
end
- # Implements Unicode-aware slice with codepoints. Slicing on one point returns the codepoints for that
- # character.
- #
- # Example:
- # 'こんにちは'.mb_chars.slice(2..3).to_s # => "にち"
- def slice(*args)
- if args.size > 2
- raise ArgumentError, "wrong number of arguments (#{args.size} for 1)" # Do as if we were native
- elsif (args.size == 2 && !(args.first.is_a?(Numeric) || args.first.is_a?(Regexp)))
- raise TypeError, "cannot convert #{args.first.class} into Integer" # Do as if we were native
- elsif (args.size == 2 && !args[1].is_a?(Numeric))
- raise TypeError, "cannot convert #{args[1].class} into Integer" # Do as if we were native
- elsif args[0].kind_of? Range
- cps = Unicode.u_unpack(@wrapped_string).slice(*args)
- result = cps.nil? ? nil : cps.pack('U*')
- elsif args[0].kind_of? Regexp
- result = @wrapped_string.slice(*args)
- elsif args.size == 1 && args[0].kind_of?(Numeric)
- character = Unicode.u_unpack(@wrapped_string)[args[0]]
- result = character && [character].pack('U')
- else
- cps = Unicode.u_unpack(@wrapped_string).slice(*args)
- result = cps && cps.pack('U*')
- end
- result && chars(result)
- end
- alias_method :[], :slice
-
# Limit the byte size of the string to a number of bytes without breaking characters. Usable
# when the storage for a string is limited for some reason.
#
@@ -265,7 +237,7 @@ module ActiveSupport #:nodoc:
chars(Unicode.tidy_bytes(@wrapped_string, force))
end
- %w(capitalize downcase lstrip reverse rstrip slice strip tidy_bytes upcase).each do |method|
+ %w(capitalize downcase lstrip reverse rstrip strip tidy_bytes upcase).each do |method|
# Only define a corresponding bang method for methods defined in the proxy; On 1.9 the proxy will
# exclude lstrip!, rstrip! and strip! because they are already work as expected on multibyte strings.
if public_method_defined?(method)