mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Fix String#byteslice for Ruby 1.9.1, 1.9.2
This commit is contained in:
parent
cd6c8fe942
commit
9af36441cf
1 changed files with 8 additions and 1 deletions
|
@ -6,6 +6,13 @@ class String
|
|||
end
|
||||
|
||||
unless method_defined? :byteslice
|
||||
alias_method :byteslice, :[]
|
||||
if RUBY_VERSION < '1.9'
|
||||
alias_method :byteslice, :[]
|
||||
else
|
||||
def byteslice(*arg)
|
||||
enc = self.encoding
|
||||
self.dup.force_encoding(Encoding::ASCII_8BIT).slice(*arg).force_encoding(enc)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue