Random::Formatter#alphanumeric
generates a random alphanumeric string.
The argument n specifies the length, in characters, of the alphanumeric string to be generated.
If n is not specified or is nil, 16 is assumed. It may be larger in the future.
The result may contain A-Z, a-z and 0-9.
require 'random/formatter' prng.alphanumeric #=> "2BuBuLf3WfSKyQbR" prng.alphanumeric(10) #=> "i6K93NdqiH"
Writes pemmable
, which must respond to to_pem
to path
with the given permissions
. If passed cipher
and passphrase
those arguments will be passed to to_pem
.
The host to connect to either from the RUBYGEMS_HOST environment variable or from the user’s configuration
Check if gem name
version version
is installed.
Zlib::GzipReader
wrapper that unzips data
.
Zlib::GzipWriter
wrapper that zips data
.
Set
the real user ID of the calling process to user. Not available on all platforms.
Set
the real group ID of the calling process to group. Not available on all platforms.
Sets the (user) real and/or effective user IDs of the current process to rid and eid, respectively. A value of -1
for either means to leave that ID unchanged. Not available on all platforms.
Sets the (group) real and/or effective group IDs of the current process to rid and eid, respectively. A value of -1
for either means to leave that ID unchanged. Not available on all platforms.
Sets the (user) real, effective, and saved user IDs of the current process to rid, eid, and sid respectively. A value of -1
for any value means to leave that ID unchanged. Not available on all platforms.
Sets the (group) real, effective, and saved user IDs of the current process to rid, eid, and sid respectively. A value of -1
for any value means to leave that ID unchanged. Not available on all platforms.
Reset nil attributes to their default values to make the spec valid
If object
is an Array object, returns object
.
Otherwise if object
responds to :to_ary
, calls object.to_ary
and returns the result.
Returns nil
if object
does not respond to :to_ary
Raises an exception unless object.to_ary
returns an Array object.
Returns the list of private methods accessible to obj. If the all parameter is set to false
, only those methods in the receiver will be listed.
Returns true
if obj is an instance of the given class. See also Object#kind_of?
.
class A; end class B < A; end class C < B; end b = B.new b.instance_of? A #=> false b.instance_of? B #=> true b.instance_of? C #=> false
If object
is an Integer object, returns object
.
Integer.try_convert(1) # => 1
Otherwise if object
responds to :to_int
, calls object.to_int
and returns the result.
Integer.try_convert(1.25) # => 1
Returns nil
if object
does not respond to :to_int
Integer.try_convert([]) # => nil
Raises an exception unless object.to_int
returns an Integer object.
If object
is a String object, returns object
.
Otherwise if object
responds to :to_str
, calls object.to_str
and returns the result.
Returns nil
if object
does not respond to :to_str
.
Raises an exception unless object.to_str
returns a String object.
Returns an array of grapheme clusters in str. This is a shorthand for str.each_grapheme_cluster.to_a
.
If a block is given, which is a deprecated form, works the same as each_grapheme_cluster
.
Returns true if str
starts with one of the prefixes
given. Each of the prefixes
should be a String
or a Regexp
.
"hello".start_with?("hell") #=> true "hello".start_with?(/H/i) #=> true # returns true if one of the prefixes matches. "hello".start_with?("heaven", "hell") #=> true "hello".start_with?("heaven", "paradise") #=> false
Performs String#tr_s
processing on str in place, returning str, or nil
if no changes were made.
Like backtrace
, but returns each line of the execution stack as a Thread::Backtrace::Location
. Accepts the same arguments as backtrace
.
f = Fiber.new { Fiber.yield } f.resume loc = f.backtrace_locations.first loc.label #=> "yield" loc.path #=> "test.rb" loc.lineno #=> 1