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"
Returns a string containing the RFC-2045-compliant Base64-encoding of bin
.
Per RFC 2045, the returned string may contain the URL-unsafe characters +
or /
; see Encoding Character Set above:
Base64.strict_encode64("\xFB\xEF\xBE") # => "++++\n" Base64.strict_encode64("\xFF\xFF\xFF") # => "////\n"
The returned string may include padding; see Padding above.
Base64.strict_encode64('*') # => "Kg==\n"
The returned string will have no newline characters, regardless of its length; see Newlines above:
Base64.strict_encode64('*') # => "Kg==" Base64.strict_encode64('*' * 46) # => "KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg=="
The string to be encoded may itself contain newlines, which will be encoded as ordinary Base64:
Base64.strict_encode64("\n\n\n") # => "CgoK" s = "This is line 1\nThis is line 2\n" Base64.strict_encode64(s) # => "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK"
Returns a string containing the decoding of an RFC-2045-compliant Base64-encoded string str
:
s = "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK" Base64.strict_decode64(s) # => "This is line 1\nThis is line 2\n"
Non-Base64 characters in str
not allowed; see Encoding Character Set above: these include newline characters and characters -
and /
:
Base64.strict_decode64("\n") # Raises ArgumentError Base64.strict_decode64('-') # Raises ArgumentError Base64.strict_decode64('_') # Raises ArgumentError
Padding in str
, if present, must be correct:
Base64.strict_decode64("MDEyMzQ1Njc") # Raises ArgumentError Base64.strict_decode64("MDEyMzQ1Njc=") # => "01234567" Base64.strict_decode64("MDEyMzQ1Njc==") # Raises ArgumentError
Returns the RFC-4648-compliant Base64-encoding of bin
.
Per RFC 4648, the returned string will not contain the URL-unsafe characters +
or /
, but instead may contain the URL-safe characters -
and _
; see Encoding Character Set above:
Base64.urlsafe_encode64("\xFB\xEF\xBE") # => "----" Base64.urlsafe_encode64("\xFF\xFF\xFF") # => "____"
By default, the returned string may have padding; see Padding, above:
Base64.urlsafe_encode64('*') # => "Kg=="
Optionally, you can suppress padding:
Base64.urlsafe_encode64('*', padding: false) # => "Kg"
The returned string will have no newline characters, regardless of its length; see Newlines above:
Base64.urlsafe_encode64('*') # => "Kg==" Base64.urlsafe_encode64('*' * 46) # => "KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg=="
Returns the decoding of an RFC-4648-compliant Base64-encoded string str
:
str
may not contain non-Base64 characters; see Encoding Character Set above:
Base64.urlsafe_decode64('+') # Raises ArgumentError. Base64.urlsafe_decode64('/') # Raises ArgumentError. Base64.urlsafe_decode64("\n") # Raises ArgumentError.
Padding in str
, if present, must be correct: see Padding, above:
Base64.urlsafe_decode64("MDEyMzQ1Njc") # => "01234567" Base64.urlsafe_decode64("MDEyMzQ1Njc=") # => "01234567" Base64.urlsafe_decode64("MDEyMzQ1Njc==") # Raises ArgumentError.
Safely write a file in binary mode on all platforms.
Is this platform Solaris?
An Array
of the default sources that come with RubyGems
Get the ‘current’ server.
In the context of execution taking place within the main thread of a dRuby server (typically, as a result of a remote call on the server or one of its objects), the current server is that server. Otherwise, the current server is the primary server.
If the above rule fails to find a server, a DRbServerNotFound
error is raised.
Get the ‘current’ server.
In the context of execution taking place within the main thread of a dRuby server (typically, as a result of a remote call on the server or one of its objects), the current server is that server. Otherwise, the current server is the primary server.
If the above rule fails to find a server, a DRbServerNotFound
error is raised.
This lexes with the Ripper
lex. It drops any space events but otherwise returns the same tokens. Raises SyntaxError
if the syntax in source is invalid.
Returns true if the source parses with errors.
Returns the code fragment that corresponds to this AST.
Note that this is an API for ruby internal use, debugging, and research. Do not use this for any other purpose. The compatibility is not guaranteed.
Also note that this API may return an incomplete code fragment that does not parse; for example, a here document following an expression may be dropped.
Returns a copy of the current source string, that was used to construct this Parser
.
Indicates whether this DH
instance has a private key associated with it or not. The private key may be retrieved with DH#priv_key.
Verifies whether the signature is valid given the message digest input. It does so by validating sig
using the public key of this DSA
instance.
Deprecated in version 3.0. Consider using PKey::PKey#sign_raw
and PKey::PKey#verify_raw
instead.
digest
A message digest of the original input data to be signed.
sig
A DSA signature value.
Indicates whether this DSA
instance has a private key associated with it or not. The private key may be retrieved with DSA#private_key.
Returns whether this EC
instance has a private key. The private key (BN
) can be retrieved with EC#private_key
.
Does this keypair contain a private key?
Writes string to the SSL
connection.
Performs the certificate verification using the parameters set to stctx.
See also the man page X509_verify_cert(3).