Results for: "strip"

Turns the database’s fast mode on or off. If fast mode is turned on, gdbm does not wait for writes to be flushed to the disk before continuing.

This option is obsolete for gdbm >= 1.8 since fast mode is turned on by default. See also: syncmode=

Iterates over the range, passing each nth element to the block. If begin and end are numeric, n is added for each iteration. Otherwise step invokes succ to iterate through range elements.

If no block is given, an enumerator is returned instead. Especially, the enumerator is an Enumerator::ArithmeticSequence if begin and end of the range are numeric.

range = Xs.new(1)..Xs.new(10)
range.step(2) {|x| puts x}
puts
range.step(3) {|x| puts x}

produces:

 1 x
 3 xxx
 5 xxxxx
 7 xxxxxxx
 9 xxxxxxxxx

 1 x
 4 xxxx
 7 xxxxxxx
10 xxxxxxxxxx

See Range for the definition of class Xs.

Returns the first object in the range, or an array of the first n elements.

(10..20).first     #=> 10
(10..20).first(3)  #=> [10, 11, 12]

Returns the last object in the range, or an array of the last n elements.

Note that with no arguments last will return the object that defines the end of the range even if exclude_end? is true.

(10..20).last      #=> 20
(10...20).last     #=> 20
(10..20).last(3)   #=> [18, 19, 20]
(10...20).last(3)  #=> [17, 18, 19]

Deletes every element that appears in the given enumerable object and returns self.

Callback invoked whenever a subclass of the current class is created.

Example:

class Foo
  def self.inherited(subclass)
    puts "New subclass: #{subclass}"
  end
end

class Bar < Foo
end

class Baz < Bar
end

produces:

New subclass: Bar
New subclass: Baz

Recursively deletes a directory, including all directories beneath it.

See FileUtils.rm_r

Writes contents to the file.

See File.write.

Writes contents to the file, opening it in binary mode.

See File.binwrite.

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.pipe?.

See FileTest.sticky?.

See FileTest.writable?.

Return scanner state of current token.

Stores a new value in the database with the given key as an index.

If the key already exists, this will update the value associated with the key.

Returns the given value.

enable the socket option IPV6_V6ONLY if IPV6_V6ONLY is available.

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

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.

Use Addrinfo.getaddrinfo instead. This method is deprecated for the following reasons:

This method obtains the host information for hostname.

p Socket.gethostbyname("hal") #=> ["localhost", ["hal"], 2, "\x7F\x00\x00\x01"]

Use Addrinfo#getnameinfo instead. This method is deprecated for the following reasons:

This method obtains the host information for address.

p Socket.gethostbyaddr([221,186,184,68].pack("CCCC"))
#=> ["carbon.ruby-lang.org", [], 2, "\xDD\xBA\xB8D"]

p Socket.gethostbyaddr([127,0,0,1].pack("CCCC"))
["localhost", [], 2, "\x7F\x00\x00\x01"]
p Socket.gethostbyaddr(([0]*15+[1]).pack("C"*16))
#=> ["localhost", ["ip6-localhost", "ip6-loopback"], 10,
     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"]

Obtains address information for nodename:servname.

Note that Addrinfo.getaddrinfo provides the same functionality in an object oriented style.

family should be an address family such as: :INET, :INET6, etc.

socktype should be a socket type such as: :STREAM, :DGRAM, :RAW, etc.

protocol should be a protocol defined in the family, and defaults to 0 for the family.

flags should be bitwise OR of Socket::AI_* constants.

Socket.getaddrinfo("www.ruby-lang.org", "http", nil, :STREAM)
#=> [["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68", 2, 1, 6]] # PF_INET/SOCK_STREAM/IPPROTO_TCP

Socket.getaddrinfo("localhost", nil)
#=> [["AF_INET", 0, "localhost", "127.0.0.1", 2, 1, 6],  # PF_INET/SOCK_STREAM/IPPROTO_TCP
#    ["AF_INET", 0, "localhost", "127.0.0.1", 2, 2, 17], # PF_INET/SOCK_DGRAM/IPPROTO_UDP
#    ["AF_INET", 0, "localhost", "127.0.0.1", 2, 3, 0]]  # PF_INET/SOCK_RAW/IPPROTO_IP

reverse_lookup directs the form of the third element, and has to be one of below. If reverse_lookup is omitted, the default value is nil.

+true+, +:hostname+:  hostname is obtained from numeric address using reverse lookup, which may take a time.
+false+, +:numeric+:  hostname is same as numeric address.
+nil+:              obey to the current +do_not_reverse_lookup+ flag.

If Addrinfo object is preferred, use Addrinfo.getaddrinfo.

creates a listening socket bound to self.

Search took: 3ms  ·  Total Results: 1884