summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cgi/core.rb4
-rw-r--r--lib/mkmf.rb2
-rw-r--r--lib/net/protocol.rb2
-rw-r--r--lib/optparse.rb2
-rw-r--r--lib/un.rb2
5 files changed, 6 insertions, 6 deletions
diff --git a/lib/cgi/core.rb b/lib/cgi/core.rb
index 3fb8dbab54..c45f9b3a9e 100644
--- a/lib/cgi/core.rb
+++ b/lib/cgi/core.rb
@@ -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
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 355ea171ee..0d9d3d9f38 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -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
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 037fcd8358..71378af804 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -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)"
diff --git a/lib/optparse.rb b/lib/optparse.rb
index c6e652971e..5cdcabf4a7 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -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
diff --git a/lib/un.rb b/lib/un.rb
index d109a3417b..14f5b10fec 100644
--- a/lib/un.rb
+++ b/lib/un.rb
@@ -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