[前][次][番号順一覧][スレッド一覧]

ruby-changes:74241

From: Nobuyoshi <ko1@a...>
Date: Tue, 25 Oct 2022 13:59:09 +0900 (JST)
Subject: [ruby-changes:74241] 71a5b1d457 (master): [ruby/tmpdir] [DOC] Improve documentation

https://git.ruby-lang.org/ruby.git/commit/?id=71a5b1d457

From 71a5b1d4573ea16e4691e0847cea7d309116e224 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 25 Oct 2022 13:39:56 +0900
Subject: [ruby/tmpdir] [DOC] Improve documentation

https://github.com/ruby/tmpdir/commit/b9c880f2b6
---
 lib/tmpdir.rb | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index 3b67164039..962393f98a 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -108,6 +108,7 @@ class Dir https://github.com/ruby/ruby/blob/trunk/lib/tmpdir.rb#L108
     end
   end
 
+  # Temporary name generator
   module Tmpname # :nodoc:
     module_function
 
@@ -115,16 +116,23 @@ class Dir https://github.com/ruby/ruby/blob/trunk/lib/tmpdir.rb#L116
       Dir.tmpdir
     end
 
+    # Unusable characters as path name
     UNUSABLE_CHARS = "^,-.0-9A-Z_a-z~"
 
-    class << (RANDOM = Random.new)
+    # Dedicated random number generator
+    RANDOM = Random.new
+    class << Random # :nodoc:
+      # Maximum random number
       MAX = 36**6 # < 0x100000000
+
+      # Returns new random string upto 6 bytes
       def next
         rand(MAX).to_s(36)
       end
     end
     private_constant :RANDOM
 
+    # Generates and yields random names to create a temporary name
     def create(basename, tmpdir=nil, max_try: nil, **opts)
       origdir = tmpdir
       tmpdir ||= tmpdir()
-- 
cgit v1.2.3


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]