Results for: "String#[]"

Returns a string created by converting each element of the set to a string See also: Array#join

Returns a string containing a human-readable representation of the set (“#<Set: {element1, element2, …}>”).

Returns a string representation of self:

Customer = Struct.new(:name, :address, :zip) # => Customer
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.inspect # => "#<struct Customer name=\"Joe Smith\", address=\"123 Maple, Anytown NC\", zip=12345>"

Returns the number of members.

Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.size #=> 3

Returns a string representation of self (including the leading colon):

:foo.inspect # => ":foo"

Related: Symbol#to_s, Symbol#name.

Equivalent to self.to_s.length; see String#length.

No documentation available

Returns true if self points to a mountpoint.

Joins the given pathnames onto self to create a new Pathname object. This is effectively the same as using Pathname#+ to append self and all arguments sequentially.

path0 = Pathname.new("/usr")                # Pathname:/usr
path0 = path0.join("bin/ruby")              # Pathname:/usr/bin/ruby
    # is the same as
path1 = Pathname.new("/usr") + "bin/ruby"   # Pathname:/usr/bin/ruby
path0 == path1
    #=> true

Iterates over the directory tree in a depth first manner, yielding a Pathname for each file under “this” directory.

Returns an Enumerator if no block is given.

Since it is implemented by the standard library module Find, Find.prune can be used to control the traversal.

If self is ., yielded pathnames begin with a filename in the current directory, not ./.

See Find.find

Recursively deletes a directory, including all directories beneath it.

See FileUtils.rm_rf

Returns all the bytes from the file, or the first N if specified.

See File.binread.

Returns all the lines from the file.

See File.readlines.

Writes contents to the file.

See File.write.

Read symbolic link.

See File.readlink.

Returns a File::Stat object.

See File.stat.

See File.lstat.

Truncates the file to length bytes.

See File.truncate.

See FileTest.exist?.

See FileTest.sticky?.

See FileTest.symlink?.

See FileTest.writable?.

Removes a file or directory, using File.unlink if self is a file, or Dir.unlink as necessary.

Binds to the given local address.

Parameter

Example

require 'socket'

# use Addrinfo
socket = Socket.new(:INET, :STREAM, 0)
socket.bind(Addrinfo.tcp("127.0.0.1", 2222))
p socket.local_address #=> #<Addrinfo: 127.0.0.1:2222 TCP>

# use struct sockaddr
include Socket::Constants
socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
socket.bind( sockaddr )

Unix-based Exceptions

On unix-based based systems the following system exceptions may be raised if the call to bind fails:

On unix-based based systems if the address family of the calling socket is Socket::AF_UNIX the follow exceptions may be raised if the call to bind fails:

Windows Exceptions

On Windows systems the following system exceptions may be raised if the call to bind fails:

See

Listens for connections, using the specified int as the backlog. A call to listen only applies if the socket is of type SOCK_STREAM or SOCK_SEQPACKET.

Parameter

Example 1

require 'socket'
include Socket::Constants
socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
socket.bind( sockaddr )
socket.listen( 5 )

Example 2 (listening on an arbitrary port, unix-based systems only):

require 'socket'
include Socket::Constants
socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
socket.listen( 1 )

Unix-based Exceptions

On unix based systems the above will work because a new sockaddr struct is created on the address ADDR_ANY, for an arbitrary port number as handed off by the kernel. It will not work on Windows, because Windows requires that the socket is bound by calling bind before it can listen.

If the backlog amount exceeds the implementation-dependent maximum queue length, the implementation’s maximum queue length will be used.

On unix-based based systems the following system exceptions may be raised if the call to listen fails:

Windows Exceptions

On Windows systems the following system exceptions may be raised if the call to listen fails:

See

Search took: 5ms  ·  Total Results: 3744