Returns the string resulting from formatting objects
into format_string
.
For details on format_string
, see Format Specifications.
Transfers control to the end of the active catch
block waiting for tag. Raises UncaughtThrowError
if there is no catch
block for the tag. The optional second parameter supplies a return value for the catch
block, which otherwise defaults to nil
. For examples, see Kernel::catch.
For positive integer n
, returns an array containing all but the first n
elements:
r = (1..4) r.drop(3) # => [4] r.drop(2) # => [3, 4] r.drop(1) # => [2, 3, 4] r.drop(0) # => [1, 2, 3, 4] r.drop(50) # => [] h = {foo: 0, bar: 1, baz: 2, bat: 3} h.drop(2) # => [[:baz, 2], [:bat, 3]]
Provides a convenient Ruby iterator which executes a block for each entry in the /etc/group
file.
The code block is passed an Group
struct.
See ::getgrent
above for details.
Example:
require 'etc' Etc.group {|g| puts g.name + ": " + g.mem.join(', ') }
Allocate size
bytes of memory and return the integer memory address for the allocated memory.
Change the size of the memory allocated at the memory location addr
to size
bytes. Returns the memory address of the reallocated memory, which may be different than the address passed in.
See any remaining errors held in queue.
Any errors you see here are probably due to a bug in Ruby’s OpenSSL
implementation.
Returns true
if the named file exists and has a zero size.
file_name can be an IO
object.
Returns true
if filepath
points to a socket, false
otherwise:
require 'socket' File.socket?(Socket.new(:INET, :STREAM)) # => true File.socket?(File.new('t.txt')) # => false
Returns true
if filepath
points to a block device, false
otherwise:
File.blockdev?('/dev/sda1') # => true File.blockdev?(File.new('t.tmp')) # => false
The directory prefix this RubyGems was installed at. If your prefix is in a standard location (ie, rubygems is installed where you’d expect it to be), then prefix returns nil.
Skips the current file or directory, restarting the loop with the next entry. If the current file is a directory, that directory will not be recursively entered. Meaningful only within the block associated with Find::find
.
See the Find
module documentation for an example.
Skips the current file or directory, restarting the loop with the next entry. If the current file is a directory, that directory will not be recursively entered. Meaningful only within the block associated with Find::find
.
See the Find
module documentation for an example.
Iterates over strongly connected component in the subgraph reachable from node.
Return value is unspecified.
each_strongly_connected_component_from
doesn’t call tsort_each_node
.
class G include TSort def initialize(g) @g = g end def tsort_each_child(n, &b) @g[n].each(&b) end def tsort_each_node(&b) @g.each_key(&b) end end graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) graph.each_strongly_connected_component_from(2) {|scc| p scc } #=> [4] # [2] graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) graph.each_strongly_connected_component_from(2) {|scc| p scc } #=> [4] # [2, 3]
Iterates over strongly connected components in a graph. The graph is represented by node and each_child.
node is the first node. each_child should have call
method which takes a node argument and yields for each child node.
Return value is unspecified.
TSort.each_strongly_connected_component_from is a class method and it doesn’t need a class to represent a graph which includes TSort
.
graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} each_child = lambda {|n, &b| graph[n].each(&b) } TSort.each_strongly_connected_component_from(1, each_child) {|scc| p scc } #=> [4] # [2, 3] # [1]
Create a new BlockLocalVariableNode
node.
Tokenize string
returning the Ruby object
Returns true
if stat is a directory, false
otherwise.
File.stat("testfile").directory? #=> false File.stat(".").directory? #=> true
def operator: () -> String
def operator: () -> String
Returns the binary operator used to modify the receiver. This method is deprecated in favor of binary_operator
.
def operator: () -> String
def operator: () -> String
Returns the binary operator used to modify the receiver. This method is deprecated in favor of binary_operator
.