Start streaming using encoding
Set
all the parameters.
Parses self
destructively and returns self
containing the rest arguments left unparsed.
Returns the list of parts for the full name of this constant. For example: [:Foo]
Returns the list of parts for the full name of this constant. For example: [:Foo]
Returns the list of parts for the full name of this constant path. For example: [:Foo, :Bar]
Returns the list of parts for the full name of this constant path. For example: [:Foo, :Bar]
Returns the list of parts for the full name of this constant. For example: [:Foo]
The character offset from the beginning of the source where this location starts.
The column number in characters where this location ends from the start of the line.
Comes from ripper, called on every parse error, msg is a string
END {} ^^^^^^
BEGIN {} ^^^^^^^^
Parse a rational from the string representation.
Returns the node id for the given backtrace location.
begin raise rescue => e loc = e.backtrace_locations.first RubyVM::AbstractSyntaxTree.node_id_for_backtrace_location(loc) end # => 0
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]
Determine if characters preceeded by a backslash should be escaped or not