mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Use delete_prefix instead of sub(/\Afixed-pattern/, '')
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a94cbf81e1
commit
c01a5ee85e
6 changed files with 8 additions and 8 deletions
|
@ -207,14 +207,14 @@ class Ripper
|
|||
end
|
||||
|
||||
def map_tokens(tokens)
|
||||
tokens.map {|pos,type,str| map_token(type.to_s.sub(/\Aon_/,'')) }.join
|
||||
tokens.map {|pos,type,str| map_token(type.to_s.delete_prefix('on_')) }.join
|
||||
end
|
||||
|
||||
MAP = {}
|
||||
seed = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
|
||||
SCANNER_EVENT_TABLE.each do |ev, |
|
||||
raise CompileError, "[RIPPER FATAL] too many system token" if seed.empty?
|
||||
MAP[ev.to_s.sub(/\Aon_/,'')] = seed.shift
|
||||
MAP[ev.to_s.delete_prefix('on_')] = seed.shift
|
||||
end
|
||||
|
||||
def map_token(tok)
|
||||
|
|
|
@ -421,7 +421,7 @@ class CGI
|
|||
module QueryExtension
|
||||
|
||||
%w[ CONTENT_LENGTH SERVER_PORT ].each do |env|
|
||||
define_method(env.sub(/^HTTP_/, '').downcase) do
|
||||
define_method(env.delete_prefix('HTTP_').downcase) do
|
||||
(val = env_table[env]) && Integer(val)
|
||||
end
|
||||
end
|
||||
|
@ -434,7 +434,7 @@ class CGI
|
|||
HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
|
||||
HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM HTTP_HOST
|
||||
HTTP_NEGOTIATE HTTP_PRAGMA HTTP_REFERER HTTP_USER_AGENT ].each do |env|
|
||||
define_method(env.sub(/^HTTP_/, '').downcase) do
|
||||
define_method(env.delete_prefix('HTTP_').downcase) do
|
||||
env_table[env]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2264,7 +2264,7 @@ RULES
|
|||
origdef ||= ''
|
||||
|
||||
if $extout and $INSTALLFILES
|
||||
$cleanfiles.concat($INSTALLFILES.collect {|files, dir|File.join(dir, files.sub(/\A\.\//, ''))})
|
||||
$cleanfiles.concat($INSTALLFILES.collect {|files, dir|File.join(dir, files.delete_prefix('./'))})
|
||||
$distcleandirs.concat($INSTALLFILES.collect {|files, dir| dir})
|
||||
end
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ module Net # :nodoc:
|
|||
read_bytes = 0
|
||||
while (line = readuntil("\r\n")) != ".\r\n"
|
||||
read_bytes += line.size
|
||||
yield line.sub(/\A\./, '')
|
||||
yield line.delete_prefix('.')
|
||||
end
|
||||
LOG_on()
|
||||
LOG "read message (#{read_bytes} bytes)"
|
||||
|
|
|
@ -1595,7 +1595,7 @@ XXX
|
|||
begin
|
||||
sw, = complete(:short, opt)
|
||||
# short option matched.
|
||||
val = arg.sub(/\A-/, '')
|
||||
val = arg.delete_prefix('-')
|
||||
has_arg = true
|
||||
rescue InvalidOption
|
||||
# if no short options match, try completion with long
|
||||
|
|
|
@ -47,7 +47,7 @@ def setup(options = "", *long_options)
|
|||
end
|
||||
long_options.each do |s|
|
||||
opt_name, arg_name = s.split(/(?=[\s=])/, 2)
|
||||
opt_name.sub!(/\A--/, '')
|
||||
opt_name.delete_prefix!('--')
|
||||
s = "--#{opt_name.gsub(/([A-Z]+|[a-z])([A-Z])/, '\1-\2').downcase}#{arg_name}"
|
||||
puts "#{opt_name}=>#{s}" if $DEBUG
|
||||
opt_name = opt_name.intern
|
||||
|
|
Loading…
Reference in a new issue