summaryrefslogtreecommitdiff
path: root/doc/examples
diff options
context:
space:
mode:
authorBurdette Lamar <BurdetteLamar@Yahoo.com>2022-09-21 16:34:55 -0500
committerGitHub <noreply@github.com>2022-09-21 16:34:55 -0500
commit56d773dc6f8a1a9ded3f20cdabf263800e5bf75d (patch)
treee5918806ebafa01732507b8cca30d633df90282e /doc/examples
parent369f1668cd9dd4f361d9082bb729aa510835126b (diff)
New page IO Streams (#6383)
This page provides an overview of IO streams. It's meant to be linked to from many other doc spots. In particular it will be linked to from many places in ARGF, File, IO, and StringIO.
Notes
Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/files.rdoc26
1 files changed, 26 insertions, 0 deletions
diff --git a/doc/examples/files.rdoc b/doc/examples/files.rdoc
new file mode 100644
index 0000000000..f736132770
--- /dev/null
+++ b/doc/examples/files.rdoc
@@ -0,0 +1,26 @@
+# English text with newlines.
+text = <<~EOT
+ First line
+ Second line
+
+ Fourth line
+ Fifth line
+EOT
+
+# Russian text.
+russian = "\u{442 435 441 442}" # => "ั‚ะตัั‚"
+
+# Binary data.
+data = "\u9990\u9991\u9992\u9993\u9994"
+
+# Text file.
+File.write('t.txt', text)
+
+# File with Russian text.
+File.write('t.rus', russian)
+
+# File with binary data.
+f = File.new('t.dat', 'wb:UTF-16')
+f.write(data)
+f.close
+