Results for: "OptionParser"

Concatenates the given object(s) to str. If an object is an Integer, it is considered a codepoint and converted to a character before concatenation.

concat can take multiple arguments, and all the arguments are concatenated in order.

a = "hello "
a.concat("world", 33)      #=> "hello world!"
a                          #=> "hello world!"

b = "sn"
b.concat("_", b, "_", b)   #=> "sn_sn_sn"

See also String#<<, which takes a single argument.

Returns the string generated by calling crypt(3) standard library function with str and salt_str, in this order, as its arguments. Please do not use this method any longer. It is legacy; provided only for backward compatibility with ruby scripts in earlier days. It is bad to use in contemporary programs for several reasons:

* Behaviour of C's <code>crypt(3)</code> depends on the OS it is
  run.  The generated string lacks data portability.

* On some OSes such as Mac OS, <code>crypt(3)</code> never fails
  (i.e. silently ends up in unexpected results).

* On some OSes such as Mac OS, <code>crypt(3)</code> is not
  thread safe.

* So-called "traditional" usage of <code>crypt(3)</code> is very
  very very weak.  According to its manpage, Linux's traditional
  <code>crypt(3)</code> output has only 2**56 variations; too
  easy to brute force today.  And this is the default behaviour.

* In order to make things robust some OSes implement so-called
  "modular" usage. To go through, you have to do a complex
  build-up of the <code>salt_str</code> parameter, by hand.
  Failure in generation of a proper salt string tends not to
  yield any errors; typos in parameters are normally not
  detectable.

    * For instance, in the following example, the second invocation
      of <code>String#crypt</code> is wrong; it has a typo in
      "round=" (lacks "s").  However the call does not fail and
      something unexpected is generated.

         "foo".crypt("$5$rounds=1000$salt$") # OK, proper usage
         "foo".crypt("$5$round=1000$salt$")  # Typo not detected

* Even in the "modular" mode, some hash functions are considered
  archaic and no longer recommended at all; for instance module
  <code>$1$</code> is officially abandoned by its author: see
  http://phk.freebsd.dk/sagas/md5crypt_eol.html .  For another
  instance module <code>$3$</code> is considered completely
  broken: see the manpage of FreeBSD.

* On some OS such as Mac OS, there is no modular mode. Yet, as
  written above, <code>crypt(3)</code> on Mac OS never fails.
  This means even if you build up a proper salt string it
  generates a traditional DES hash anyways, and there is no way
  for you to be aware of.

      "foo".crypt("$5$rounds=1000$salt$") # => "$5fNPQMxC5j6."

If for some reason you cannot migrate to other secure contemporary password hashing algorithms, install the string-crypt gem and require 'string/crypt' to continue using it.

Returns the Symbol corresponding to str, creating the symbol if it did not previously exist. See Symbol#id2name.

"Koala".intern         #=> :Koala
s = 'cat'.to_sym       #=> :cat
s == :cat              #=> true
s = '@cat'.to_sym      #=> :@cat
s == :@cat             #=> true

This can also be used to create symbols that cannot be represented using the :xxx notation.

'cat and dog'.to_sym   #=> :"cat and dog"

Centers str in width. If width is greater than the length of str, returns a new String of length width with str centered and padded with padstr; otherwise, returns str.

"hello".center(4)         #=> "hello"
"hello".center(20)        #=> "       hello        "
"hello".center(20, '123') #=> "1231231hello12312312"

Returns a new String with the last character removed. If the string ends with \r\n, both characters are removed. Applying chop to an empty string returns an empty string. String#chomp is often a safer alternative, as it leaves the string unchanged if it doesn’t end in a record separator.

"string\r\n".chop   #=> "string"
"string\n\r".chop   #=> "string\n"
"string\n".chop     #=> "string"
"string".chop       #=> "strin"
"x".chop.chop       #=> ""

Returns a copy of the receiver with trailing whitespace removed. See also String#lstrip and String#strip.

Refer to String#strip for the definition of whitespace.

"  hello  ".rstrip   #=> "  hello"
"hello".rstrip       #=> "hello"

Processes str as for String#chop, returning str, or nil if str is the empty string. See also String#chomp!.

Removes trailing whitespace from the receiver. Returns the altered receiver, or nil if no change was made. See also String#lstrip! and String#strip!.

Refer to String#strip for the definition of whitespace.

"  hello  ".rstrip!  #=> "  hello"
"  hello".rstrip!    #=> nil
"hello".rstrip!      #=> nil

Returns 0 if the value is positive, pi otherwise.

Returns 0 if the value is positive, pi otherwise.

provides a unified clone operation, for REXML::XPathParser to use across multiple Object types

Returns an array with both numeric and float represented as Float objects.

This is achieved by converting numeric to a Float.

1.2.coerce(3)       #=> [3.0, 1.2]
2.5.coerce(1.1)     #=> [1.1, 2.5]

Returns true if float is 0.0.

Returns true if float is greater than 0.

Returns true if float is less than 0.

Returns the numerator. The result is machine dependent.

n = 0.3.numerator    #=> 5404319552844595
d = 0.3.denominator  #=> 18014398509481984
n.fdiv(d)            #=> 0.3

See also Float#denominator.

Transfer control to another fiber, resuming it from where it last stopped or starting it if it was not resumed before. The calling fiber will be suspended much like in a call to Fiber.yield. You need to require 'fiber' before using this method.

The fiber which receives the transfer call is treats it much like a resume call. Arguments passed to transfer are treated like those passed to resume.

You cannot resume a fiber that transferred control to another one. This will cause a double resume error. You need to transfer control back to this fiber before it can yield and resume.

Example:

fiber1 = Fiber.new do
  puts "In Fiber 1"
  Fiber.yield
end

fiber2 = Fiber.new do
  puts "In Fiber 2"
  fiber1.transfer
  puts "Never see this message"
end

fiber3 = Fiber.new do
  puts "In Fiber 3"
end

fiber2.resume
fiber3.resume

produces

In fiber 2
In fiber 1
In fiber 3

The optional encoding keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used.

With no block, open is a synonym for Dir::new. If a block is present, it is passed aDir as a parameter. The directory is closed at the end of the block, and Dir::open returns the value of the block.

Returns the path parameter passed to dir’s constructor.

d = Dir.new("..")
d.path   #=> ".."

Seeks to a particular location in dir. integer must be a value returned by Dir#tell.

d = Dir.new("testdir")   #=> #<Dir:0x401b3c40>
d.read                   #=> "."
i = d.tell               #=> 12
d.read                   #=> ".."
d.seek(i)                #=> #<Dir:0x401b3c40>
d.read                   #=> ".."

Closes the directory stream. Calling this method on closed Dir object is ignored since Ruby 2.3.

d = Dir.new("testdir")
d.close   #=> nil

Returns true if the named file is an empty directory, false if it is not a directory or non-empty.

Returns the last access time for the named file as a Time object.

file_name can be an IO object.

File.atime("testfile")   #=> Wed Apr 09 08:51:48 CDT 2003

Returns the modification time for the named file as a Time object.

file_name can be an IO object.

File.mtime("testfile")   #=> Tue Apr 08 12:58:04 CDT 2003

Returns the change time for the named file (the time at which directory information about the file was changed, not the file itself).

file_name can be an IO object.

Note that on Windows (NTFS), returns creation time (birth time).

File.ctime("testfile")   #=> Wed Apr 09 08:53:13 CDT 2003
Search took: 5ms  ·  Total Results: 4416