creates an Addrinfo
object from the arguments.
The arguments are interpreted as similar to self.
Addrinfo.tcp("0.0.0.0", 4649).family_addrinfo("www.ruby-lang.org", 80) #=> #<Addrinfo: 221.186.184.68:80 TCP (www.ruby-lang.org:80)> Addrinfo.unix("/tmp/sock").family_addrinfo("/tmp/sock2") #=> #<Addrinfo: /tmp/sock2 SOCK_STREAM>
creates a new Socket
connected to the address of local_addrinfo
.
If local_addrinfo is nil, the address of the socket is not bound.
The timeout specify the seconds for timeout. Errno::ETIMEDOUT is raised when timeout occur.
If a block is given the created socket is yielded for each address.
Returns true for IPv6 link local address (ff80::/10). It returns false otherwise.
Returns true for IPv6 site local address (ffc0::/10). It returns false otherwise.
Returns the Encoding
object that represents the encoding of the file. If strio is write mode and no encoding is specified, returns nil
.
Returns the Encoding
of the internal string if conversion is specified. Otherwise returns nil.
Duplicates a StringScanner
object.
Tests whether the given pattern
is matched from the current scan pointer. Advances the scan pointer if advance_pointer_p
is true. Returns the matched string if return_string_p
is true. The match register is affected.
“full” means “#scan with full parameters”.
Scans the string until the pattern
is matched. Advances the scan pointer if advance_pointer_p
, otherwise not. Returns the matched string if return_string_p
is true, otherwise returns the number of bytes advanced. This method does affect the match register.
Executes the given block within the context of the receiver (obj). In order to set the context, the variable self
is set to obj while the code is executing, giving the code access to obj’s instance variables. Arguments are passed as block parameters.
class KlassWithSecret def initialize @secret = 99 end end k = KlassWithSecret.new k.instance_exec(5) {|x| @secret+x } #=> 104
Calls block once for each key in hsh, passing the value as a parameter.
If no block is given, an enumerator is returned instead.
h = { "a" => 100, "b" => 200 } h.each_value {|value| puts value }
produces:
100 200
Return an array containing the values associated with the given keys. Also see Hash.select
.
h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" } h.values_at("cow", "cat") #=> ["bovine", "feline"]
Returns an array containing the values associated with the given keys but also raises KeyError
when one of keys can’t be found. Also see Hash#values_at
and Hash#fetch
.
h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" } h.fetch_values("cow", "cat") #=> ["bovine", "feline"] h.fetch_values("cow", "bird") # raises KeyError h.fetch_values("cow", "bird") { |k| k.upcase } #=> ["bovine", "BIRD"]
Returns true
if the given value is present for some key in hsh.
h = { "a" => 100, "b" => 200 } h.has_value?(100) #=> true h.has_value?(999) #=> false
Yields each environment variable value
.
An Enumerator
is returned if no block was given.
Returns an array containing the environment variable values associated with the given names. See also ENV.select
.
Returns true
if there is an environment variable with the given value
.
Synonym for ENV
.
Serialization support for the object returned by _getobj_.
Reinitializes delegation from a serialized object.
Add option switch like with on
, but at tail of summary.
Add option switch like with on
, but at tail of summary.