summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorBurdette Lamar <BurdetteLamar@Yahoo.com>2022-03-22 14:51:05 -0500
committerGitHub <noreply@github.com>2022-03-22 14:51:05 -0500
commit0140e6c41e4669e157c5a99b9d4b5b0fa153359b (patch)
tree0a8e557ad39cd70d2135734c8e91ddeecfdcb1d1 /doc
parent26aff37466fa3226122c65f49f2b7663e6b2551b (diff)
[DOC] Enhanced RDoc for String (#5685)
Treats: #chars #codepoints #each_char #each_codepoint #each_grapheme_cluster #grapheme_clusters Also, corrects a passage in #unicode_normalize that mentioned module UnicodeNormalize, whose doc (:nodoc:, actually) says not to mention it.
Notes
Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/string/chars.rdoc5
-rw-r--r--doc/string/codepoints.rdoc6
-rw-r--r--doc/string/each_char.rdoc17
-rw-r--r--doc/string/each_codepoint.rdoc18
-rw-r--r--doc/string/each_grapheme_cluster.rdoc12
-rw-r--r--doc/string/grapheme_clusters.rdoc6
6 files changed, 64 insertions, 0 deletions
diff --git a/doc/string/chars.rdoc b/doc/string/chars.rdoc
new file mode 100644
index 0000000000..d24a1cc3a9
--- /dev/null
+++ b/doc/string/chars.rdoc
@@ -0,0 +1,5 @@
+Returns an array of the characters in +self+:
+
+ 'hello'.chars # => ["h", "e", "l", "l", "o"]
+ 'тест'.chars # => ["т", "е", "с", "т"]
+ 'こんにちは'.chars # => ["こ", "ん", "に", "ち", "は"]
diff --git a/doc/string/codepoints.rdoc b/doc/string/codepoints.rdoc
new file mode 100644
index 0000000000..0c55d3f4b9
--- /dev/null
+++ b/doc/string/codepoints.rdoc
@@ -0,0 +1,6 @@
+Returns an array of the codepoints in +self+;
+each codepoint is the integer value for a character:
+
+ 'hello'.codepoints # => [104, 101, 108, 108, 111]
+ 'тест'.codepoints # => [1090, 1077, 1089, 1090]
+ 'こんにちは'.codepoints # => [12371, 12435, 12395, 12385, 12399]
diff --git a/doc/string/each_char.rdoc b/doc/string/each_char.rdoc
new file mode 100644
index 0000000000..e5ae5a1812
--- /dev/null
+++ b/doc/string/each_char.rdoc
@@ -0,0 +1,17 @@
+Calls the given block with each successive character from +self+;
+returns +self+:
+
+ 'hello'.each_char {|char| print char, ' ' }
+ print "\n"
+ 'тест'.each_char {|char| print char, ' ' }
+ print "\n"
+ 'こんにちは'.each_char {|char| print char, ' ' }
+ print "\n"
+
+Output:
+
+ h e l l o
+ т е с т
+ こ ん に ち は
+
+Returns an enumerator if no block is given.
diff --git a/doc/string/each_codepoint.rdoc b/doc/string/each_codepoint.rdoc
new file mode 100644
index 0000000000..88bfcbd1c0
--- /dev/null
+++ b/doc/string/each_codepoint.rdoc
@@ -0,0 +1,18 @@
+Calls the given block with each successive codepoint from +self+;
+each codepoint is the integer value for a character;
+returns +self+:
+
+ 'hello'.each_codepoint {|codepoint| print codepoint, ' ' }
+ print "\n"
+ 'тест'.each_codepoint {|codepoint| print codepoint, ' ' }
+ print "\n"
+ 'こんにちは'.each_codepoint {|codepoint| print codepoint, ' ' }
+ print "\n"
+
+Output:
+
+ 104 101 108 108 111
+ 1090 1077 1089 1090
+ 12371 12435 12395 12385 12399
+
+Returns an enumerator if no block is given.
diff --git a/doc/string/each_grapheme_cluster.rdoc b/doc/string/each_grapheme_cluster.rdoc
new file mode 100644
index 0000000000..40be95fcac
--- /dev/null
+++ b/doc/string/each_grapheme_cluster.rdoc
@@ -0,0 +1,12 @@
+Calls the given block with each successive grapheme cluster from +self+
+(see {Unicode Grapheme Cluster Boundaries}[https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries]);
+returns +self+:
+
+ s = "\u0061\u0308-pqr-\u0062\u0308-xyz-\u0063\u0308" # => "ä-pqr-b̈-xyz-c̈"
+ s.each_grapheme_cluster {|gc| print gc, ' ' }
+
+Output:
+
+ ä - p q r - b̈ - x y z - c̈
+
+Returns an enumerator if no block is given.
diff --git a/doc/string/grapheme_clusters.rdoc b/doc/string/grapheme_clusters.rdoc
new file mode 100644
index 0000000000..8c7f5a7259
--- /dev/null
+++ b/doc/string/grapheme_clusters.rdoc
@@ -0,0 +1,6 @@
+Returns an array of the grapheme clusters in +self+
+(see {Unicode Grapheme Cluster Boundaries}[https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries]):
+
+ s = "\u0061\u0308-pqr-\u0062\u0308-xyz-\u0063\u0308" # => "ä-pqr-b̈-xyz-c̈"
+ s.grapheme_clusters
+ # => ["ä", "-", "p", "q", "r", "-", "b̈", "-", "x", "y", "z", "-", "c̈"]