Formats and writes to the stream converting parameters under control of the format string.
See Kernel#sprintf
for format string details.
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
.
SecureRandom.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 'securerandom' SecureRandom.alphanumeric #=> "2BuBuLf3WfSKyQbR" SecureRandom.alphanumeric(10) #=> "i6K93NdqiH"
If a secure random number generator is not available, NotImplementedError
is raised.
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 an array of instance variable names for the receiver. Note that simply defining an accessor does not create the corresponding instance variable.
class Fred attr_accessor :a1 def initialize @iv = 3 end end Fred.new.instance_variables #=> [:@iv]
Returns the factorization of self
.
See Prime#prime_division
for more details.
Iterates the given block over all prime numbers.
See Prime
#each for more details.
Returns true
if the named file is writable by the real user and group id of this process. See access(3).
Note that some OS-level security features may cause this to return true even though the file is not writable by the real user/group.
If file_name is writable by others, returns an integer representing the file permission bits of file_name. Returns nil
otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2)
.
file_name can be an IO
object.
File.world_writable?("/tmp") #=> 511 m = File.world_writable?("/tmp") sprintf("%o", m) #=> "777"
Return a list of the local variable names defined where this NameError
exception was raised.
Internal use only.
Return true if the caused method was called as private.
When this module is included in another, Ruby calls append_features
in this module, passing it the receiving module in mod. Ruby’s default implementation is to add the constants, methods, and module variables of this module to mod if this module has not already been added to mod or one of its ancestors. See also Module#include
.
When this module is prepended in another, Ruby calls prepend_features
in this module, passing it the receiving module in mod. Ruby’s default implementation is to overlay the constants, methods, and module variables of this module to mod if this module has not already been added to mod or one of its ancestors. See also Module#prepend
.
Creates an accessor method to allow assignment to the attribute symbol.id2name
. String
arguments are converted to symbols. Returns an array of defined method names as symbols.
Returns an array of the names of class variables in mod. This includes the names of class variables in any included modules, unless the inherit parameter is set to false
.
class One @@var1 = 1 end class Two < One @@var2 = 2 end One.class_variables #=> [:@@var1] Two.class_variables #=> [:@@var2, :@@var1] Two.class_variables(false) #=> [:@@var2]
Makes a list of existing constants private.
Returns true if the given year is a leap year of the proleptic Gregorian calendar.
Date.gregorian_leap?(1900) #=> false Date.gregorian_leap?(2000) #=> true