[ruby/tmpdir] [DOC] Improve documentation
https://github.com/ruby/tmpdir/commit/b9c880f2b6
This commit is contained in:
parent
d76284dfb7
commit
71a5b1d457
@ -108,6 +108,7 @@ class Dir
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Temporary name generator
|
||||||
module Tmpname # :nodoc:
|
module Tmpname # :nodoc:
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
@ -115,16 +116,23 @@ class Dir
|
|||||||
Dir.tmpdir
|
Dir.tmpdir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Unusable characters as path name
|
||||||
UNUSABLE_CHARS = "^,-.0-9A-Z_a-z~"
|
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
|
MAX = 36**6 # < 0x100000000
|
||||||
|
|
||||||
|
# Returns new random string upto 6 bytes
|
||||||
def next
|
def next
|
||||||
rand(MAX).to_s(36)
|
rand(MAX).to_s(36)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private_constant :RANDOM
|
private_constant :RANDOM
|
||||||
|
|
||||||
|
# Generates and yields random names to create a temporary name
|
||||||
def create(basename, tmpdir=nil, max_try: nil, **opts)
|
def create(basename, tmpdir=nil, max_try: nil, **opts)
|
||||||
origdir = tmpdir
|
origdir = tmpdir
|
||||||
tmpdir ||= tmpdir()
|
tmpdir ||= tmpdir()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user