Add the –prerelease option to the option parser.
Like Enumerable#map
, but chains operation to be lazy-evaluated.
(1..Float::INFINITY).lazy.map {|i| i**2 } #=> #<Enumerator::Lazy: #<Enumerator::Lazy: 1..Infinity>:map> (1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) #=> [1, 4, 9]
Like Enumerable#select
, but chains operation to be lazy-evaluated.
Sends a SELECT command to select a mailbox
so that messages in the mailbox
can be accessed.
After you have selected a mailbox, you may retrieve the number of items in that mailbox from @responses[-1], and the number of recent messages from @responses[-1]. Note that these values can change if new messages arrive during a session; see add_response_handler()
for a way of detecting this event.
A Net::IMAP::NoResponseError
is raised if the mailbox does not exist or is for some reason non-selectable.
Returns the canceled status.
Selects specified components from URI
.
require 'uri' uri = URI.parse('http://myuser:mypass@my.example.com/test.rbx') uri.select(:userinfo, :host, :path) # => ["myuser:mypass", "my.example.com", "/test.rbx"]
If a block is provided, returns a new array containing [key, value] pairs for which the block returns true.
Otherwise, same as values_at
Undo escaping such as that done by CGI.escapeElement()
print CGI.unescapeElement( CGI.escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG") # "<BR><A HREF="url"></A>" print CGI.unescapeElement( CGI.escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"]) # "<BR><A HREF="url"></A>"
Returns whether the form contained multipart/form-data
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]
Changes the encoding to encoding
and returns self.
Returns true for a string which is encoded correctly.
"\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
Unicode Normalization—Returns a normalized form of str
, using Unicode normalizations NFC, NFD, NFKC, or NFKD. The normalization form used is determined by form
, which can be 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 other than UTF-8 is implemented by converting to UTF-8, which makes it slower than UTF-8.
"a\u0300".unicode_normalize #=> "\u00E0" "a\u0300".unicode_normalize(:nfc) #=> "\u00E0" "\u00E0".unicode_normalize(:nfd) #=> "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.