Returns the hostname.
p Socket.gethostname #=> "hal"
Note that it is not guaranteed to be able to convert to IP address using gethostbyname, getaddrinfo, etc. If you need local IP address, use Socket.ip_address_list
.
Obtains the host information for hostname.
p Socket.gethostbyname("hal") #=> ["localhost", ["hal"], 2, "\x7F\x00\x00\x01"]
Lookups host information by hostname.
TCPSocket.gethostbyname("localhost") #=> ["localhost", ["hal"], 2, "127.0.0.1"]
How String Gem paths should be split. Overridable for esoteric platforms.
Converts a pathname to an absolute pathname. Relative paths are referenced from the current working directory of the process unless dir_string
is given, in which case it will be used as the starting point. The given pathname may start with a “~
”, which expands to the process owner’s home directory (the environment variable HOME
must be set correctly). “~
user” expands to the named user’s home directory.
File.expand_path("~oracle/bin") #=> "/home/oracle/bin"
A simple example of using dir_string
is as follows.
File.expand_path("ruby", "/usr/bin") #=> "/usr/bin/ruby"
A more complex example which also resolves parent directory is as follows. Suppose we are in bin/mygem and want the absolute path of lib/mygem.rb.
File.expand_path("../../lib/mygem.rb", __FILE__) #=> ".../path/to/project/lib/mygem.rb"
So first it resolves the parent of __FILE__, that is bin/, then go to the parent, the root of the project and appends lib/mygem.rb
.
Program name to be emitted in error message and default banner, defaults to $0.
Program name to be emitted in error message and default banner, defaults to $0.
Returns the original name of the method.
Returns the original name of the method.