Convert self
to locale encoding
Convert self
to locale encoding
Returns a Digest
subclass by name
require 'openssl' OpenSSL::Digest("MD5") # => OpenSSL::Digest::MD5 Digest("Foo") # => NameError: wrong constant name Foo
Returns a Digest
subclass by name
require 'openssl' OpenSSL::Digest("MD5") # => OpenSSL::Digest::MD5 Digest("Foo") # => NameError: wrong constant name Foo
See any remaining errors held in queue.
Any errors you see here are probably due to a bug in Ruby’s OpenSSL
implementation.
Load yaml
in to a Ruby data structure. If multiple documents are provided, the object contained in the first document will be returned. filename
will be used in the exception message if any exception is raised while parsing. If yaml
is empty, it returns the specified fallback
return value, which defaults to false
.
Raises a Psych::SyntaxError
when a YAML
syntax error is detected.
Example:
Psych.load("--- a") # => 'a' Psych.load("---\n - a\n - b") # => ['a', 'b'] begin Psych.load("--- `", filename: "file.txt") rescue Psych::SyntaxError => ex ex.file # => 'file.txt' ex.message # => "(file.txt): found character that cannot start any token" end
When the optional symbolize_names
keyword argument is set to a true value, returns symbols for keys in Hash
objects (default: strings).
Psych.load("---\n foo: bar") # => {"foo"=>"bar"} Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
Raises a TypeError
when ‘yaml` parameter is NilClass
. This method is similar to `safe_load` except that `Symbol` objects are allowed by default.
Returns a default parser
Spawns the specified command on a newly allocated pty. You can also use the alias ::getpty
.
The command’s controlling tty is set to the slave device of the pty and its standard input/output/error is redirected to the slave device.
env
is an optional hash that provides additional environment variables to the spawned pty.
# sets FOO to "bar" PTY.spawn({"FOO"=>"bar"}, "printenv", "FOO") { |r,w,pid| p r.read } #=> "bar\r\n" # unsets FOO PTY.spawn({"FOO"=>nil}, "printenv", "FOO") { |r,w,pid| p r.read } #=> ""
command
and command_line
are the full commands to run, given a String
. Any additional arguments
will be passed to the command.
In the non-block form this returns an array of size three, [r, w, pid]
.
In the block form these same values will be yielded to the block:
Closes the syslog facility. Raises a runtime exception if it is not open.
Calculates Adler-32 checksum for string
, and returns updated value of adler
. If string
is omitted, it returns the Adler-32 initial value. If adler
is omitted, it assumes that the initial value is given to adler
. If string
is an IO
instance, reads from the IO
until the IO
returns nil and returns Adler-32 of all read data.
Example usage:
require "zlib" data = "foo" puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}" #=> Adler32 checksum: 2820145
Returns true
if the named file exists and has a zero size.
file_name can be an IO
object.
Returns true
if filepath
points to a block device, false
otherwise:
File.blockdev?('/dev/sda1') # => true File.blockdev?(File.new('t.tmp')) # => false
Returns the currently set formatter. By default, it is set to DidYouMean::Formatter
.
Updates the primary formatter used to format the suggestions.
Is uri
the URI
for the current local server?
Set
the changed state of this object. Notifications will be sent only if the changed state
is true
.
state
Boolean indicating the changed state of this Observable
.
Returns true if this object’s state has been changed since the last notify_observers
call.
URI::regexp([match_schemes])
match_schemes
Array
of schemes. If given, resulting regexp matches to URIs whose scheme is one of the match_schemes.
Returns a Regexp
object which matches to URI-like strings. The Regexp
object returned by this method includes arbitrary number of capture group (parentheses). Never rely on its number.
require 'uri' # extract first URI from html_string html_string.slice(URI.regexp) # remove ftp URIs html_string.sub(URI.regexp(['ftp']), '') # You should not rely on the number of parentheses html_string.scan(URI.regexp) do |*matches| p $& end
Raises a TypeError
to prevent cloning.