Merges two URIs.
require 'uri' uri = URI.parse("http://my.example.com") uri.merge("/main.rbx?page=1") # => "http://my.example.com/main.rbx?page=1"
Logs data
at level
if the given level is above the current log level.
Same as BasicLog#log
Suggests gems based on the supplied gem_name
. Returns an array of alternative gem names.
creates TCP/IP server sockets for host and port. host is optional.
If no block given, it returns an array of listening sockets.
If a block is given, the block is called with the sockets. The value of the block is returned. The socket is closed when this method returns.
If port is 0, actual port number is chosen dynamically. However all sockets in the result has same port number.
# tcp_server_sockets returns two sockets. sockets = Socket.tcp_server_sockets(1296) p sockets #=> [#<Socket:fd 3>, #<Socket:fd 4>] # The sockets contains IPv6 and IPv4 sockets. sockets.each {|s| p s.local_address } #=> #<Addrinfo: [::]:1296 TCP> # #<Addrinfo: 0.0.0.0:1296 TCP> # IPv6 and IPv4 socket has same port number, 53114, even if it is chosen dynamically. sockets = Socket.tcp_server_sockets(0) sockets.each {|s| p s.local_address } #=> #<Addrinfo: [::]:53114 TCP> # #<Addrinfo: 0.0.0.0:53114 TCP> # The block is called with the sockets. Socket.tcp_server_sockets(0) {|sockets| p sockets #=> [#<Socket:fd 3>, #<Socket:fd 4>] }
Creates UDP/IP sockets for a UDP server.
If no block given, it returns an array of sockets.
If a block is given, the block is called with the sockets. The value of the block is returned. The sockets are closed when this method returns.
If port is zero, some port is chosen. But the chosen port is used for the all sockets.
# UDP/IP echo server Socket.udp_server_sockets(0) {|sockets| p sockets.first.local_address.ip_port #=> 32963 Socket.udp_server_loop_on(sockets) {|msg, msg_src| msg_src.reply msg } }
Receive UDP/IP packets from the given sockets. For each packet received, the block is called.
The block receives msg and msg_src. msg is a string which is the payload of the received packet. msg_src is a Socket::UDPSource
object which is used for reply.
Socket.udp_server_loop
can be implemented using this method as follows.
udp_server_sockets(host, port) {|sockets| loop { readable, _, _ = IO.select(sockets) udp_server_recv(readable) {|msg, msg_src| ... } } }
creates a UNIX server socket on path
If no block given, it returns a listening socket.
If a block is given, it is called with the socket and the block value is returned. When the block exits, the socket is closed and the socket file is removed.
socket = Socket.unix_server_socket("/tmp/s") p socket #=> #<Socket:fd 3> p socket.local_address #=> #<Addrinfo: /tmp/s SOCK_STREAM> Socket.unix_server_socket("/tmp/sock") {|s| p s #=> #<Socket:fd 3> p s.local_address #=> # #<Addrinfo: /tmp/sock SOCK_STREAM> }
Returns WIN32OLE
object for a specific dispatch or dual interface specified by iid.
ie = WIN32OLE.new('InternetExplorer.Application') ie_web_app = ie.ole_query_interface('{0002DF05-0000-0000-C000-000000000046}') # => WIN32OLE object for dispinterface IWebBrowserApp
Returns the value of the local variable symbol
.
def foo a = 1 binding.local_variable_get(:a) #=> 1 binding.local_variable_get(:b) #=> NameError end
This method is the short version of the following code:
binding.eval("#{symbol}")
Task
description for the clobber rdoc task or its renamed equivalent
obj can be an instance of InternalObjectWrapper
.
Note that you should not use this method in your application.
Sets a list of characters which can be used to quote a substring of the line. Completion occurs on the entire substring, and within the substring Readline.completer_word_break_characters
are treated as any other character, unless they also appear within this list.
Raises NotImplementedError
if the using readline library does not support.
Gets a list of characters which can be used to quote a substring of the line.
Raises NotImplementedError
if the using readline library does not support.
Verify internal consistency.
This method is implementation specific. Now this method checks generational consistency if RGenGC is supported.
Returns the size of memory allocated by malloc().
Only available if ruby was built with CALC_EXACT_MALLOC_SIZE
.
The file name and line number of the caller of the caller of this method.
depth
is how many layers up the call stack it should go.
e.g.,
def a; Gem.location_of_caller
; end a #=> [“x.rb”, 2] # (it’ll vary depending on file name and line number)
def b; c; end def c; Gem.location_of_caller(2)
; end b #=> [“x.rb”, 6] # (it’ll vary depending on file name and line number)
Returns the latest release version of RubyGems.