summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorBurdette Lamar <BurdetteLamar@Yahoo.com>2022-03-29 09:54:29 -0500
committerGitHub <noreply@github.com>2022-03-29 09:54:29 -0500
commitb257034ae55da80d9b3f059a7504ee78c4e70980 (patch)
tree130ccdf8b22ae47d73c28b52e4f97d258a184b15 /doc
parentc67088dbae9e61a4c07742ceee7fb46597589d95 (diff)
[DOC] Enhanced RDoc for String (#5730)
Treats: #start_with? #end_with? #delete_prefix #delete_prefix! #delete_suffix #delete_suffix!
Notes
Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/string/delete_prefix.rdoc8
-rw-r--r--doc/string/delete_suffix.rdoc8
-rw-r--r--doc/string/end_with_p.rdoc11
-rw-r--r--doc/string/start_with_p.rdoc18
4 files changed, 45 insertions, 0 deletions
diff --git a/doc/string/delete_prefix.rdoc b/doc/string/delete_prefix.rdoc
new file mode 100644
index 0000000000..fa9d8abd38
--- /dev/null
+++ b/doc/string/delete_prefix.rdoc
@@ -0,0 +1,8 @@
+Returns a copy of +self+ with leading substring <tt>prefix</tt> removed:
+
+ 'hello'.delete_prefix('hel') # => "lo"
+ 'hello'.delete_prefix('llo') # => "hello"
+ 'тест'.delete_prefix('те') # => "ст"
+ 'こんにちは'.delete_prefix('こん') # => "にちは"
+
+Related: String#delete_prefix!, String#delete_suffix.
diff --git a/doc/string/delete_suffix.rdoc b/doc/string/delete_suffix.rdoc
new file mode 100644
index 0000000000..4862b725cf
--- /dev/null
+++ b/doc/string/delete_suffix.rdoc
@@ -0,0 +1,8 @@
+Returns a copy of +self+ with trailing substring <tt>suffix</tt> removed:
+
+ 'hello'.delete_suffix('llo') # => "he"
+ 'hello'.delete_suffix('hel') # => "hello"
+ 'тест'.delete_suffix('ст') # => "те"
+ 'こんにちは'.delete_suffix('ちは') # => "こんに"
+
+Related: String#delete_suffix!, String#delete_prefix.
diff --git a/doc/string/end_with_p.rdoc b/doc/string/end_with_p.rdoc
new file mode 100644
index 0000000000..f959cf7aaa
--- /dev/null
+++ b/doc/string/end_with_p.rdoc
@@ -0,0 +1,11 @@
+Returns whether +self+ ends with any of the given +strings+.
+
+Returns +true+ if any given string matches the end, +false+ otherwise:
+
+ 'hello'.end_with?('ello') #=> true
+ 'hello'.end_with?('heaven', 'ello') #=> true
+ 'hello'.end_with?('heaven', 'paradise') #=> false
+ 'тест'.end_with?('т') # => true
+ 'こんにちは'.end_with?('は') # => true
+
+Related: String#start_with?.
diff --git a/doc/string/start_with_p.rdoc b/doc/string/start_with_p.rdoc
new file mode 100644
index 0000000000..1cfed76296
--- /dev/null
+++ b/doc/string/start_with_p.rdoc
@@ -0,0 +1,18 @@
+Returns whether +self+ starts with any of the given +string_or_regexp+.
+
+Matches patterns against the beginning of+self+.
+For each given +string_or_regexp+, the pattern is:
+
+- +string_or_regexp+ itself, if it is a Regexp.
+- <tt>Regexp.quote(string_or_regexp)</tt>, if +string_or_regexp+ is a string.
+
+Returns +true+ if any pattern matches the beginning, +false+ otherwise:
+
+ 'hello'.start_with?('hell') # => true
+ 'hello'.start_with?(/H/i) # => true
+ 'hello'.start_with?('heaven', 'hell') # => true
+ 'hello'.start_with?('heaven', 'paradise') # => false
+ 'тест'.start_with?('т') # => true
+ 'こんにちは'.start_with?('こ') # => true
+
+Related: String#end_with?.