Add local/remote options to the command line parser.
Add the –bulk-threshold option
Add the –clear-sources option
Returns a URL-encoded string derived from the given string str
.
The returned string:
Preserves:
Characters '*'
, '.'
, '-'
, and '_'
.
Character in ranges 'a'..'z'
, 'A'..'Z'
, and '0'..'9'
.
Example:
URI.encode_www_form_component('*.-_azAZ09') # => "*.-_azAZ09"
Converts:
Character ' '
to character '+'
.
Any other character to “percent notation”; the percent notation for character c is '%%%X' % c.ord
.
Example:
URI.encode_www_form_component('Here are some punctuation characters: ,;?:') # => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A"
Encoding:
If str
has encoding Encoding::ASCII_8BIT, argument enc
is ignored.
Otherwise str
is converted first to Encoding::UTF_8 (with suitable character replacements), and then to encoding enc
.
In either case, the returned string has forced encoding Encoding::US_ASCII.
Related: URI.encode_uri_component
(encodes ' '
as '%20'
).
Compile a UntilNode
node
Dispatch enter and leave events for UntilNode
nodes and continue walking the tree.
Inspect a UntilNode
node.
Copy a UntilNode
node
Removes session from the session cache.
Changes the encoding of self
to encoding
, which may be a string encoding name or an Encoding
object; returns self:
s = 'łał' s.bytes # => [197, 130, 97, 197, 130] s.encoding # => #<Encoding:UTF-8> s.force_encoding('ascii') # => "\xC5\x82a\xC5\x82" s.encoding # => #<Encoding:US-ASCII>
Does not change the underlying bytes:
s.bytes # => [197, 130, 97, 197, 130]
Makes the change even if the given encoding
is invalid for self
(as is the change above):
s.valid_encoding? # => false s.force_encoding(Encoding::UTF_8) # => "łał" s.valid_encoding? # => true
Returns true
if self
is encoded correctly, false
otherwise:
"\xc2\xa1".force_encoding("UTF-8").valid_encoding? # => true "\xc2".force_encoding("UTF-8").valid_encoding? # => false "\x80".force_encoding("UTF-8").valid_encoding? # => false
Returns a copy of self
with Unicode normalization applied.
Argument form
must be one of the following symbols (see Unicode normalization forms):
:nfc
: Canonical decomposition, followed by canonical composition.
:nfd
: Canonical decomposition.
:nfkc
: Compatibility decomposition, followed by canonical composition.
:nfkd
: Compatibility decomposition.
The encoding of self
must be one of:
Encoding::UTF_8
Encoding::UTF_16BE
Encoding::UTF_16LE
Encoding::UTF_32BE
Encoding::UTF_32LE
Encoding::GB18030
Encoding::UCS_2BE
Encoding::UCS_4BE
Examples:
"a\u0300".unicode_normalize # => "a" "\u00E0".unicode_normalize(:nfd) # => "a "
Related: String#unicode_normalize!
, String#unicode_normalized?
.
Like String#unicode_normalize
, except that the normalization is performed on self
.
Related String#unicode_normalized?
.
Returns true
if self
is in the given form
of Unicode normalization, false
otherwise. The form
must be one of :nfc
, :nfd
, :nfkc
, or :nfkd
.
Examples:
"a\u0300".unicode_normalized? # => false "a\u0300".unicode_normalized?(:nfd) # => true "\u00E0".unicode_normalized? # => true "\u00E0".unicode_normalized?(:nfd) # => false
Raises an exception if self
is not in a Unicode encoding:
s = "\xE0".force_encoding('ISO-8859-1') s.unicode_normalized? # Raises Encoding::CompatibilityError.
Related: String#unicode_normalize
, String#unicode_normalize!
.
Returns whether ASCII-compatible or not.
Encoding::UTF_8.ascii_compatible? #=> true Encoding::UTF_16BE.ascii_compatible? #=> false
Returns the singleton class of obj. This method creates a new singleton class if obj does not have one.
If obj is nil
, true
, or false
, it returns NilClass
, TrueClass
, or FalseClass
, respectively. If obj is an Integer
, a Float
or a Symbol
, it raises a TypeError
.
Object.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>> String.singleton_class #=> #<Class:String> nil.singleton_class #=> NilClass
Returns the list of protected 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 formatted string of exception. The returned string is formatted using the same format that Ruby uses when printing an uncaught exceptions to stderr.
If highlight is true
the default error handler will send the messages to a tty.
order must be either of :top
or :bottom
, and places the error message and the innermost backtrace come at the top or the bottom.
The default values of these options depend on $stderr
and its tty?
at the timing of a call.