Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Pathname#socket?
() -> untyped
socket? → true or false
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 2481
def socket?() FileTest.socket?(@path) end
Returns whether entry at the path in self is a socket:
Example
require 'socket' sock_path = '/tmp/socket' sock_pn = Pathname(sock_path) sock_pn.exist? # => false sock_pn.socket? # => false server = UNIXServer.new(sock_path) sock_pn.exist? # => true sock_pn.socket? # => true # Clean up. server.close sock_pn.delete file_path = '/etc/passwd' file_pn = Pathname(file_path) file_pn.file? # => true file_pn.socket? # => false
Returns false on Windows.