Results for: "tally"

Returns self, for backward compatibility.

Returns true if the named file is writable by the effective user and group id of this process. See eaccess(3).

Note that some OS-level security features may cause this to return true even though the file is not writable by the effective user/group.

Returns true if the named file is executable by the effective user and group id of this process. See eaccess(3).

Windows does not support execute permissions separately from read permissions. On Windows, a file is only considered executable if it ends in .bat, .cmd, .com, or .exe.

Note that some OS-level security features may cause this to return true even though the file is not executable by the effective user/group.

Returns true if the named files are identical.

file_1 and file_2 can be an IO object.

open("a", "w") {}
p File.identical?("a", "a")      #=> true
p File.identical?("a", "./a")    #=> true
File.link("a", "b")
p File.identical?("a", "b")      #=> true
File.symlink("a", "c")
p File.identical?("a", "c")      #=> true
open("d", "w") {}
p File.identical?("a", "d")      #=> false

Initiates garbage collection, even if manually disabled.

This method is defined with keyword arguments that default to true:

def GC.start(full_mark: true, immediate_sweep: true); end

Use full_mark: false to perform a minor GC. Use immediate_sweep: false to defer sweeping (use lazy sweep).

Note: These keyword arguments are implementation and version dependent. They are not guaranteed to be future-compatible, and may be ignored if the underlying implementation does not support them.

Returns a Hash containing information about the GC.

The contents of the hash are implementation specific and may change in the future without notice.

The hash includes information about internal statistics about GC such as:

count

The total number of garbage collections ran since application start (count includes both minor and major garbage collections)

time

The total time spent in garbage collections (in milliseconds)

heap_allocated_pages

The total number of ‘:heap_eden_pages` + `:heap_tomb_pages`

heap_sorted_length

The number of pages that can fit into the buffer that holds references to all pages

heap_allocatable_pages

The total number of pages the application could allocate without additional GC

heap_available_slots

The total number of slots in all ‘:heap_allocated_pages`

heap_live_slots

The total number of slots which contain live objects

heap_free_slots

The total number of slots which do not contain live objects

heap_final_slots

The total number of slots with pending finalizers to be run

heap_marked_slots

The total number of objects marked in the last GC

heap_eden_pages

The total number of pages which contain at least one live slot

heap_tomb_pages

The total number of pages which do not contain any live slots

total_allocated_pages

The cumulative number of pages allocated since application start

total_freed_pages

The cumulative number of pages freed since application start

total_allocated_objects

The cumulative number of objects allocated since application start

total_freed_objects

The cumulative number of objects freed since application start

malloc_increase_bytes

Amount of memory allocated on the heap for objects. Decreased by any GC

malloc_increase_bytes_limit

When ‘:malloc_increase_bytes` crosses this limit, GC is triggered

minor_gc_count

The total number of minor garbage collections run since process start

major_gc_count

The total number of major garbage collections run since process start

compact_count

The total number of compactions run since process start

read_barrier_faults

The total number of times the read barrier was triggered during compaction

total_moved_objects

The total number of objects compaction has moved

remembered_wb_unprotected_objects

The total number of objects without write barriers

remembered_wb_unprotected_objects_limit

When ‘:remembered_wb_unprotected_objects` crosses this limit, major GC is triggered

old_objects

Number of live, old objects which have survived at least 3 garbage collections

old_objects_limit

When ‘:old_objects` crosses this limit, major GC is triggered

oldmalloc_increase_bytes

Amount of memory allocated on the heap for objects. Decreased by major GC

oldmalloc_increase_bytes_limit

When ‘:old_malloc_increase_bytes` crosses this limit, major GC is triggered

If the optional argument, hash, is given, it is overwritten and returned. This is intended to avoid probe effect.

This method is only expected to work on CRuby.

Returns the elapsed real time used to execute the given block.

Returns the elapsed real time used to execute the given block.

No documentation available
No documentation available

The path to the data directory specified by the gem name. If the package is not available as a gem, return nil.

Splits a string into an array of tokens in the same way the UNIX Bourne shell does.

argv = Shellwords.split('here are "two words"')
argv #=> ["here", "are", "two words"]

Note, however, that this is not a command line parser. Shell metacharacters except for the single and double quotes and backslash are not treated as such.

argv = Shellwords.split('ruby my_prog.rb | less')
argv #=> ["ruby", "my_prog.rb", "|", "less"]

String#shellsplit is a shortcut for this function.

argv = 'here are "two words"'.shellsplit
argv #=> ["here", "are", "two words"]
No documentation available

Splits a string into an array of tokens in the same way the UNIX Bourne shell does.

argv = Shellwords.split('here are "two words"')
argv #=> ["here", "are", "two words"]

Note, however, that this is not a command line parser. Shell metacharacters except for the single and double quotes and backslash are not treated as such.

argv = Shellwords.split('ruby my_prog.rb | less')
argv #=> ["ruby", "my_prog.rb", "|", "less"]

String#shellsplit is a shortcut for this function.

argv = 'here are "two words"'.shellsplit
argv #=> ["here", "are", "two words"]
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.

SyntaxSuggest.invalid? [Private]

Opposite of ‘SyntaxSuggest.valid?`

SyntaxSuggest.valid? [Private]

Returns truthy if a given input source is valid syntax

SyntaxSuggest.valid?(<<~EOM) # => true
  def foo
  end
EOM

SyntaxSuggest.valid?(<<~EOM) # => false
  def foo
    def bar # Syntax error here
  end
EOM

You can also pass in an array of lines and they’ll be joined before evaluating

SyntaxSuggest.valid?(
  [
    "def foo\n",
    "end\n"
  ]
) # => true

SyntaxSuggest.valid?(
  [
    "def foo\n",
    "  def bar\n", # Syntax error here
    "end\n"
  ]
) # => false

As an FYI the CodeLine class instances respond to ‘to_s` so passing a CodeLine in as an object or as an array will convert it to it’s code representation.

Returns the arc tangent of y and x in radians.

Examples:

atan2(-1.0, -1.0) # => -2.356194490192345  # -3*PI/4
atan2(-1.0, 0.0)  # => -1.5707963267948966 # -PI/2
atan2(-1.0, 1.0)  # => -0.7853981633974483 # -PI/4
atan2(0.0, -1.0)  # => 3.141592653589793   # PI

Returns the tangent of x in radians.

Examples:

tan(-PI)   # => 1.2246467991473532e-16  # -0.0000000000000001
tan(-PI/2) # => -1.633123935319537e+16  # -16331239353195370.0
tan(0.0)   # => 0.0
tan(PI/2)  # => 1.633123935319537e+16   # 16331239353195370.0
tan(PI)    # => -1.2246467991473532e-16 # -0.0000000000000001

Returns the arc tangent of x.

Examples:

atan(-INFINITY) # => -1.5707963267948966 # -PI2
atan(-PI)       # => -1.2626272556789115
atan(-PI/2)     # => -1.0038848218538872
atan(0.0)       # => 0.0
atan(PI/2)      # => 1.0038848218538872
atan(PI)        # => 1.2626272556789115
atan(INFINITY)  # => 1.5707963267948966  # PI/2
Search took: 2ms  ·  Total Results: 1206