Results for: "strip"

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

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

This method lookups host information by hostname.

TCPSocket.gethostbyname("localhost")
#=> ["localhost", ["hal"], 2, "127.0.0.1"]

Appends the given string to the underlying buffer string. The stream must be opened for writing. If the argument is not a string, it will be converted to a string using to_s. Returns the number of bytes written. See IO#write.

Truncates the buffer string to at most integer bytes. The stream must be opened for writing.

Attempts to skip over the given pattern beginning with the scan pointer. If it matches, the scan pointer is advanced to the end of the match, and the length of the match is returned. Otherwise, nil is returned.

It’s similar to scan, but without returning the matched string.

s = StringScanner.new('test string')
p s.skip(/\w+/)   # -> 4
p s.skip(/\w+/)   # -> nil
p s.skip(/\s+/)   # -> 1
p s.skip("st")    # -> 2
p s.skip(/\w+/)   # -> 4
p s.skip(/./)     # -> nil

Looks ahead to see if the pattern exists anywhere in the string, without advancing the scan pointer. This predicates whether a scan_until will return a value.

s = StringScanner.new('test string')
s.exist? /s/            # -> 3
s.scan /test/           # -> "test"
s.exist? /s/            # -> 2
s.exist? /e/            # -> nil

Returns true if and only if there is more data in the string. See eos?. This method is obsolete; use eos? instead.

s = StringScanner.new('test string')
s.eos?              # These two
s.rest?             # are opposites.

Returns the “rest” of the string (i.e. everything after the scan pointer). If there is no more data (eos? = true), it returns "".

s.restsize is equivalent to s.rest_size. This method is obsolete; use rest_size instead.

Returns array of WIN32OLE_VARIABLE objects which represent variables defined in OLE class.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
vars = tobj.variables
vars.each do |v|
  puts "#{v.name} = #{v.value}"
end

The result of above sample script is follows:
  xlChart = -4109
  xlDialogSheet = -4116
  xlExcel4IntlMacroSheet = 4
  xlExcel4MacroSheet = 3
  xlWorksheet = -4167

Hash#store is an alias for Hash#[]=.

Associates the given value with the given key; returns value.

If the given key exists, replaces its value with the given value; the ordering is not affected (see Entry Order):

h = {foo: 0, bar: 1}
h[:foo] = 2 # => 2
h.store(:bar, 3) # => 3
h # => {:foo=>2, :bar=>3}

If key does not exist, adds the key and value; the new entry is last in the order (see Entry Order):

h = {foo: 0, bar: 1}
h[:baz] = 2 # => 2
h.store(:bat, 3) # => 3
h # => {:foo=>0, :bar=>1, :baz=>2, :bat=>3}

ENV.store is an alias for ENV.[]=.

Creates, updates, or deletes the named environment variable, returning the value. Both name and value may be instances of String. See Valid Names and Values.

Raises an exception if name or value is invalid. See Invalid Names and Values.

Writes string if inplace mode.

Writes the given object(s) to ios. Returns nil.

The stream must be opened for writing. Each given object that isn’t a string will be converted by calling its to_s method. When called without arguments, prints the contents of $_.

If the output field separator ($,) is not nil, it is inserted between objects. If the output record separator ($\) is not nil, it is appended to the output.

$stdout.print("This is ", 100, " percent.\n")

produces:

This is 100 percent.

Formats and writes to ios, converting parameters under control of the format string. See Kernel#sprintf for details.

Sets the current file to the next file in ARGV. If there aren’t any more files it has no effect.

For example:

$ ruby argf.rb foo bar
ARGF.filename  #=> "foo"
ARGF.skip
ARGF.filename  #=> "bar"

Creates or retrieves cached CSV objects. For arguments and options, see CSV.new.

This API is not Ractor-safe.


With no block given, returns a CSV object.

The first call to instance creates and caches a CSV object:

s0 = 's0'
csv0 = CSV.instance(s0)
csv0.class # => CSV

Subsequent calls to instance with that same string or io retrieve that same cached object:

csv1 = CSV.instance(s0)
csv1.class # => CSV
csv1.equal?(csv0) # => true # Same CSV object

A subsequent call to instance with a different string or io creates and caches a different CSV object.

s1 = 's1'
csv2 = CSV.instance(s1)
csv2.equal?(csv0) # => false # Different CSV object

All the cached objects remains available:

csv3 = CSV.instance(s0)
csv3.equal?(csv0) # true # Same CSV object
csv4 = CSV.instance(s1)
csv4.equal?(csv2) # true # Same CSV object

When a block is given, calls the block with the created or retrieved CSV object; returns the block’s return value:

CSV.instance(s0) {|csv| :foo } # => :foo
No documentation available
No documentation available

Set the handling of the ordering of options and arguments. A RuntimeError is raised if option processing has already started.

The supplied value must be a member of GetoptLong::ORDERINGS. It alters the processing of options as follows:

REQUIRE_ORDER :

Options are required to occur before non-options.

Processing of options ends as soon as a word is encountered that has not been preceded by an appropriate option flag.

For example, if -a and -b are options which do not take arguments, parsing command line arguments of ‘-a one -b two’ would result in ‘one’, ‘-b’, ‘two’ being left in ARGV, and only (‘-a’, ”) being processed as an option/arg pair.

This is the default ordering, if the environment variable POSIXLY_CORRECT is set. (This is for compatibility with GNU getopt_long.)

PERMUTE :

Options can occur anywhere in the command line parsed. This is the default behavior.

Every sequence of words which can be interpreted as an option (with or without argument) is treated as an option; non-option words are skipped.

For example, if -a does not require an argument and -b optionally takes an argument, parsing ‘-a one -b two three’ would result in (‘-a’,”) and (‘-b’, ‘two’) being processed as option/arg pairs, and ‘one’,‘three’ being left in ARGV.

If the ordering is set to PERMUTE but the environment variable POSIXLY_CORRECT is set, REQUIRE_ORDER is used instead. This is for compatibility with GNU getopt_long.

RETURN_IN_ORDER :

All words on the command line are processed as options. Words not preceded by a short or long option flag are passed as arguments with an option of ” (empty string).

For example, if -a requires an argument but -b does not, a command line of ‘-a one -b two three’ would result in option/arg pairs of (‘-a’, ‘one’) (‘-b’, ”), (”, ‘two’), (”, ‘three’) being processed.

Returns true if the ipaddr is an IPv4 address.

Returns true if the ipaddr is an IPv6 address.

Returns true if the ipaddr is a private address. IPv4 addresses in 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 as defined in RFC 1918 and IPv6 Unique Local Addresses in fc00::/7 as defined in RFC 4193 are considered private.

Puts option summary into to and returns to. Yields each line if a block is given.

to

Output destination, which must have method <<. Defaults to [].

width

Width of left side, defaults to @summary_width.

max

Maximum length allowed for left side, defaults to width - 1.

indent

Indentation, defaults to @summary_indent.

Increases left margin after newline with indent for line breaks added in the block.

Search took: 5ms  ·  Total Results: 1486