Results for: "tally"

No documentation available

Escapes a string so that it can be safely used in a Bourne shell command line. str can be a non-string object that responds to to_s.

Note that a resulted string should be used unquoted and is not intended for use in double quotes nor in single quotes.

argv = Shellwords.escape("It's better to give than to receive")
argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive"

String#shellescape is a shorthand for this function.

argv = "It's better to give than to receive".shellescape
argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive"

# Search files in lib for method definitions
pattern = "^[ \t]*def "
open("| grep -Ern -e #{pattern.shellescape} lib") { |grep|
  grep.each_line { |line|
    file, lineno, matched_line = line.split(':', 3)
    # ...
  }
}

It is the caller’s responsibility to encode the string in the right encoding for the shell environment where this string is used.

Multibyte characters are treated as multibyte characters, not as bytes.

Returns an empty quoted String if str has a length of zero.

Escapes a string so that it can be safely used in a Bourne shell command line. str can be a non-string object that responds to to_s.

Note that a resulted string should be used unquoted and is not intended for use in double quotes nor in single quotes.

argv = Shellwords.escape("It's better to give than to receive")
argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive"

String#shellescape is a shorthand for this function.

argv = "It's better to give than to receive".shellescape
argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive"

# Search files in lib for method definitions
pattern = "^[ \t]*def "
open("| grep -Ern -e #{pattern.shellescape} lib") { |grep|
  grep.each_line { |line|
    file, lineno, matched_line = line.split(':', 3)
    # ...
  }
}

It is the caller’s responsibility to encode the string in the right encoding for the shell environment where this string is used.

Multibyte characters are treated as multibyte characters, not as bytes.

Returns an empty quoted String if str has a length of zero.

Builds a command line string from an argument list, array.

All elements are joined into a single string with fields separated by a space, where each element is escaped for the Bourne shell and stringified using to_s.

ary = ["There's", "a", "time", "and", "place", "for", "everything"]
argv = Shellwords.join(ary)
argv #=> "There\\'s a time and place for everything"

Array#shelljoin is a shortcut for this function.

ary = ["Don't", "rock", "the", "boat"]
argv = ary.shelljoin
argv #=> "Don\\'t rock the boat"

You can also mix non-string objects in the elements as allowed in Array#join.

output = `#{['ps', '-p', $$].shelljoin}`

Builds a command line string from an argument list, array.

All elements are joined into a single string with fields separated by a space, where each element is escaped for the Bourne shell and stringified using to_s.

ary = ["There's", "a", "time", "and", "place", "for", "everything"]
argv = Shellwords.join(ary)
argv #=> "There\\'s a time and place for everything"

Array#shelljoin is a shortcut for this function.

ary = ["Don't", "rock", "the", "boat"]
argv = ary.shelljoin
argv #=> "Don\\'t rock the boat"

You can also mix non-string objects in the elements as allowed in Array#join.

output = `#{['ps', '-p', $$].shelljoin}`

Returns the singleton instance.

Computes the arc tangent given y and x. Returns a Float in the range -PI..PI. Return value is a angle in radians between the positive x-axis of cartesian plane and the point given by the coordinates (x, y) on it.

Domain: (-INFINITY, INFINITY)

Codomain: [-PI, PI]

Math.atan2(-0.0, -1.0) #=> -3.141592653589793
Math.atan2(-1.0, -1.0) #=> -2.356194490192345
Math.atan2(-1.0, 0.0)  #=> -1.5707963267948966
Math.atan2(-1.0, 1.0)  #=> -0.7853981633974483
Math.atan2(-0.0, 1.0)  #=> -0.0
Math.atan2(0.0, 1.0)   #=> 0.0
Math.atan2(1.0, 1.0)   #=> 0.7853981633974483
Math.atan2(1.0, 0.0)   #=> 1.5707963267948966
Math.atan2(1.0, -1.0)  #=> 2.356194490192345
Math.atan2(0.0, -1.0)  #=> 3.141592653589793
Math.atan2(INFINITY, INFINITY)   #=> 0.7853981633974483
Math.atan2(INFINITY, -INFINITY)  #=> 2.356194490192345
Math.atan2(-INFINITY, INFINITY)  #=> -0.7853981633974483
Math.atan2(-INFINITY, -INFINITY) #=> -2.356194490192345

Computes the tangent of x (expressed in radians).

Domain: (-INFINITY, INFINITY)

Codomain: (-INFINITY, INFINITY)

Math.tan(0) #=> 0.0

Computes the arc tangent of x. Returns -PI/2..PI/2.

Domain: (-INFINITY, INFINITY)

Codomain: (-PI/2, PI/2)

Math.atan(0) #=> 0.0

Computes the hyperbolic tangent of x (expressed in radians).

Domain: (-INFINITY, INFINITY)

Codomain: (-1, 1)

Math.tanh(0) #=> 0.0

Computes the inverse hyperbolic tangent of x.

Domain: (-1, 1)

Codomain: (-INFINITY, INFINITY)

Math.atanh(1) #=> Infinity

Sends the given signal to the specified process id(s) if pid is positive. If pid is zero, signal is sent to all processes whose group ID is equal to the group ID of the process. If pid is negative, results are dependent on the operating system. signal may be an integer signal number or a POSIX signal name (either with or without a SIG prefix). If signal is negative (or starts with a minus sign), kills process groups instead of processes. Not all signals are available on all platforms. The keys and values of Signal.list are known signal names and numbers, respectively.

pid = fork do
   Signal.trap("HUP") { puts "Ouch!"; exit }
   # ... do some work ...
end
# ...
Process.kill("HUP", pid)
Process.wait

produces:

Ouch!

If signal is an integer but wrong for signal, Errno::EINVAL or RangeError will be raised. Otherwise unless signal is a String or a Symbol, and a known signal name, ArgumentError will be raised.

Also, Errno::ESRCH or RangeError for invalid pid, Errno::EPERM when failed because of no privilege, will be raised. In these cases, signals may have been sent to preceding processes.

Some operating systems retain the status of terminated child processes until the parent collects that status (normally using some variant of wait()). If the parent never collects this status, the child stays around as a zombie process. Process::detach prevents this by setting up a separate Ruby thread whose sole job is to reap the status of the process pid when it terminates. Use detach only when you do not intend to explicitly wait for the child to terminate.

The waiting thread returns the exit status of the detached process when it terminates, so you can use Thread#join to know the result. If specified pid is not a valid child process ID, the thread returns nil immediately.

The waiting thread has pid method which returns the pid.

In this first example, we don’t reap the first child process, so it appears as a zombie in the process status display.

p1 = fork { sleep 0.1 }
p2 = fork { sleep 0.2 }
Process.waitpid(p2)
sleep 2
system("ps -ho pid,state -p #{p1}")

produces:

27389 Z

In the next example, Process::detach is used to reap the child automatically.

p1 = fork { sleep 0.1 }
p2 = fork { sleep 0.2 }
Process.detach(p1)
Process.waitpid(p2)
sleep 2
system("ps -ho pid,state -p #{p1}")

(produces no output)

Example:

x.foo
 ^^^^
x.foo(42)
 ^^^^
x&.foo
 ^^^^^
x[42]
 ^^^^
x += 1
  ^

Example:

x.foo(42)
      ^^
x[42]
  ^^
x += 1
     ^

Example:

x + 1
  ^
+x
^

Example:

x + 1
    ^

Example:

foo(42)
^^^
foo 42
^^^

Example:

foo(42)
    ^^
foo 42
    ^^

State Transition Table Serialization

Get all gem names from the command line.

Returns every spec that matches name and optional requirements.

Activate TLS_FALLBACK_SCSV for this context. See RFC 7507.

No documentation available

Like Enumerable#map, but chains operation to be lazy-evaluated.

(1..Float::INFINITY).lazy.map {|i| i**2 }
#=> #<Enumerator::Lazy: #<Enumerator::Lazy: 1..Infinity>:map>
(1..Float::INFINITY).lazy.map {|i| i**2 }.first(3)
#=> [1, 4, 9]
Search took: 5ms  ·  Total Results: 1169