Is this tar entry a directory?
@return [String] a string suitable for debugging
DO NOT USE THIS DIRECTLY.
Hook method to return whether the obj can respond to id method or not.
When the method name parameter is given as a string, the string is converted to a symbol.
See respond_to?
, and the example of BasicObject
.
Iterates the given block for each element with an arbitrary object, obj
, and returns obj
If no block is given, returns a new Enumerator
.
to_three = Enumerator.new do |y| 3.times do |x| y << x end end to_three_with_string = to_three.with_object("foo") to_three_with_string.each do |x,string| puts "#{string}: #{x}" end # => foo:0 # => foo:1 # => foo:2
Returns true
if ios will be closed on exec.
f = open("/dev/null") f.close_on_exec? #=> false f.close_on_exec = true f.close_on_exec? #=> true f.close_on_exec = false f.close_on_exec? #=> false
Sets a close-on-exec flag.
f = open("/dev/null") f.close_on_exec = true system("cat", "/proc/self/fd/#{f.fileno}") # cat: /proc/self/fd/3: No such file or directory f.closed? #=> false
Ruby sets close-on-exec flags of all file descriptors by default since Ruby 2.0.0. So you don’t need to set by yourself. Also, unsetting a close-on-exec flag can cause file descriptor leak if another thread use fork() and exec() (via system() method for example). If you really needs file descriptor inheritance to child process, use spawn()‘s argument such as fd=>fd.
Makes the set compare its elements by their identity and returns self. This method may not be supported by all subclasses of Set
.
Returns true if the set will compare its elements by their identity. Also see Set#compare_by_identity
.
Returns a relative path from the given base_directory
to the receiver.
If self
is absolute, then base_directory
must be absolute too.
If self
is relative, then base_directory
must be relative too.
This method doesn’t access the filesystem. It assumes no symlinks.
ArgumentError
is raised when it cannot find a relative path.
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> }
creates a UNIX socket server on path. It calls the block for each socket accepted.
If host is specified, it is used with port to determine the server ports.
The socket is not closed when the block returns. So application should close it.
This method deletes the socket file pointed by path at first if the file is a socket file and it is owned by the user of the application. This is safe only if the directory of path is not changed by a malicious user. So don’t use /tmp/malicious-users-directory/socket. Note that /tmp/socket and /tmp/your-private-directory/socket is safe assuming that /tmp has sticky bit.
# Sequential echo server. # It services only one client at a time. Socket.unix_server_loop("/tmp/sock") {|sock, client_addrinfo| begin IO.copy_stream(sock, sock) ensure sock.close end }
Unpacks sockaddr into port and ip_address.
sockaddr should be a string or an addrinfo for AF_INET/AF_INET6.
sockaddr = Socket.sockaddr_in(80, "127.0.0.1") p sockaddr #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" p Socket.unpack_sockaddr_in(sockaddr) #=> [80, "127.0.0.1"]
Packs path as an AF_UNIX
sockaddr string.
Socket.sockaddr_un("/tmp/sock") #=> "\x01\x00/tmp/sock\x00\x00..."
Returns true for IPv6 unique local address (fc00::/7, RFC4193). It returns false otherwise.
Makes hsh compare its keys by their identity, i.e. it will consider exact same objects as same keys.
h1 = { "a" => 100, "b" => 200, :c => "c" } h1["a"] #=> 100 h1.compare_by_identity h1.compare_by_identity? #=> true h1["a".dup] #=> nil # different objects. h1[:c] #=> "c" # same symbols are all same.
Returns true
if hsh will compare its keys by their identity. Also see Hash#compare_by_identity
.
Returns IO
instance tied to ARGF for writing if inplace mode is enabled.