If a doctype includes an ATTLIST declaration, it will cause this method to be called. The content is the declaration itself, unparsed. EG, <!ATTLIST el attr CDATA REQUIRED> will come to this method as “el attr CDATA REQUIRED”. This is the same for all of the .*decl methods.
<!NOTATION …>
Called when <![CDATA[ … ]]> is encountered in a document. @p content “…”
Builder for an RSS
object Creates an object of the type passed in args
Executes the block
to populate elements of the created RSS
object
Returns collection of supported makers
Can I remove this method?
Simple deprecation method that deprecates name
by wrapping it up in a dummy method. It warns on each call to the dummy method telling the user of repl
(unless repl
is :none) and the year/month that it is planned to go away.
Simple deprecation method that deprecates name
by wrapping it up in a dummy method. It warns on each call to the dummy method telling the user of repl
(unless repl
is :none) and the year/month that it is planned to go away.
A Zlib::Inflate#inflate
wrapper
Same as Array#each
, but passes the index
of the element instead of the element itself.
An Enumerator
is returned if no block is given.
a = [ "a", "b", "c" ] a.each_index {|x| print x, " -- " }
produces:
0 -- 1 -- 2 --
Same as Array#each
, but traverses self
in reverse order.
a = [ "a", "b", "c" ] a.reverse_each {|x| print x, " " }
produces:
c b a
Returns an array containing the elements in self
corresponding to the given selector
(s).
The selectors may be either integer indices or ranges.
See also Array#select
.
a = %w{ a b c d e f } a.values_at(1, 3, 5) # => ["b", "d", "f"] a.values_at(1, 3, 5, 7) # => ["b", "d", "f", nil] a.values_at(-1, -2, -2, -7) # => ["f", "e", "e", nil] a.values_at(4..6, 3...6) # => ["e", "f", nil, "d", "e", "f"]
Deletes the element at the specified index
, returning that element, or nil
if the index
is out of range.
See also Array#slice!
a = ["ant", "bat", "cat", "dog"] a.delete_at(2) #=> "cat" a #=> ["ant", "bat", "dog"] a.delete_at(99) #=> nil
By using binary search, finds an index of a value from this array which meets the given condition in O(log n) where n is the size of the array.
It supports two modes, depending on the nature of the block and they are exactly the same as in the case of bsearch
method with the only difference being that this method returns the index of the element instead of the element itself. For more details consult the documentation for bsearch
.
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.
Iterates the given block over all prime numbers.
See Prime
#each for more details.
Returns a normalized form of str
, using Unicode normalizations NFC, NFD, NFKC, or NFKD. The normalization form used is determined by form
, which is any of the four values :nfc, :nfd, :nfkc, or :nfkd. The default is :nfc.
If the string is not in a Unicode Encoding
, then an Exception
is raised. In this context, ‘Unicode Encoding’ means any of UTF-8, UTF-16BE/LE, and UTF-32BE/LE, as well as GB18030, UCS_2BE, and UCS_4BE. Anything else than UTF-8 is implemented by converting to UTF-8, which makes it slower than UTF-8.
Examples
"a\u0300".unicode_normalize #=> 'à' (same as "\u00E0") "a\u0300".unicode_normalize(:nfc) #=> 'à' (same as "\u00E0") "\u00E0".unicode_normalize(:nfd) #=> 'à' (same as "a\u0300") "\xE0".force_encoding('ISO-8859-1').unicode_normalize(:nfd) #=> Encoding::CompatibilityError raised
Destructive version of String#unicode_normalize
, doing Unicode normalization in place.
Checks whether str
is in Unicode normalization form form
, which is any of the four values :nfc, :nfd, :nfkc, or :nfkd. The default is :nfc.
If the string is not in a Unicode Encoding
, then an Exception
is raised. For details, see String#unicode_normalize
.
Examples
"a\u0300".unicode_normalized? #=> false "a\u0300".unicode_normalized?(:nfd) #=> true "\u00E0".unicode_normalized? #=> true "\u00E0".unicode_normalized?(:nfd) #=> false "\xE0".force_encoding('ISO-8859-1').unicode_normalized? #=> Encoding::CompatibilityError raised
Splits str using the supplied parameter as the record separator ($/
by default), passing each substring in turn to the supplied block. If a zero-length record separator is supplied, the string is split into paragraphs delimited by multiple successive newlines.
If no block is given, an enumerator is returned instead.
print "Example one\n" "hello\nworld".each_line {|s| p s} print "Example two\n" "hello\nworld".each_line('l') {|s| p s} print "Example three\n" "hello\n\n\nworld".each_line('') {|s| p s}
produces:
Example one "hello\n" "world" Example two "hel" "l" "o\nworl" "d" Example three "hello\n\n\n" "world"
Passes each byte in str to the given block, or returns an enumerator if no block is given.
"hello".each_byte {|c| print c, ' ' }
produces:
104 101 108 108 111
Passes the Integer
ordinal of each character in str, also known as a codepoint when applied to Unicode strings to the given block.
If no block is given, an enumerator is returned instead.
"hello\u0639".each_codepoint {|c| print c, ' ' }
produces:
104 101 108 108 111 1593
Returns the next representable floating-point number.
Float::MAX.next_float and Float::INFINITY.next_float is Float::INFINITY
.
Float::NAN.next_float is Float::NAN
.
For example:
p 0.01.next_float #=> 0.010000000000000002 p 1.0.next_float #=> 1.0000000000000002 p 100.0.next_float #=> 100.00000000000001 p 0.01.next_float - 0.01 #=> 1.734723475976807e-18 p 1.0.next_float - 1.0 #=> 2.220446049250313e-16 p 100.0.next_float - 100.0 #=> 1.4210854715202004e-14 f = 0.01; 20.times { printf "%-20a %s\n", f, f.to_s; f = f.next_float } #=> 0x1.47ae147ae147bp-7 0.01 # 0x1.47ae147ae147cp-7 0.010000000000000002 # 0x1.47ae147ae147dp-7 0.010000000000000004 # 0x1.47ae147ae147ep-7 0.010000000000000005 # 0x1.47ae147ae147fp-7 0.010000000000000007 # 0x1.47ae147ae148p-7 0.010000000000000009 # 0x1.47ae147ae1481p-7 0.01000000000000001 # 0x1.47ae147ae1482p-7 0.010000000000000012 # 0x1.47ae147ae1483p-7 0.010000000000000014 # 0x1.47ae147ae1484p-7 0.010000000000000016 # 0x1.47ae147ae1485p-7 0.010000000000000018 # 0x1.47ae147ae1486p-7 0.01000000000000002 # 0x1.47ae147ae1487p-7 0.010000000000000021 # 0x1.47ae147ae1488p-7 0.010000000000000023 # 0x1.47ae147ae1489p-7 0.010000000000000024 # 0x1.47ae147ae148ap-7 0.010000000000000026 # 0x1.47ae147ae148bp-7 0.010000000000000028 # 0x1.47ae147ae148cp-7 0.01000000000000003 # 0x1.47ae147ae148dp-7 0.010000000000000031 # 0x1.47ae147ae148ep-7 0.010000000000000033 f = 0.0 100.times { f += 0.1 } p f #=> 9.99999999999998 # should be 10.0 in the ideal world. p 10-f #=> 1.9539925233402755e-14 # the floating-point error. p(10.0.next_float-10) #=> 1.7763568394002505e-15 # 1 ulp (units in the last place). p((10-f)/(10.0.next_float-10)) #=> 11.0 # the error is 11 ulp. p((10-f)/(10*Float::EPSILON)) #=> 8.8 # approximation of the above. p "%a" % f #=> "0x1.3fffffffffff5p+3" # the last hex digit is 5. 16 - 5 = 11 ulp.