Writes out text, substituting special characters beforehand. out
A String
, IO
, or any other object supporting <<( String
) input
the text to substitute and the write out
z=utf8.unpack("U*") ascOut="" z.each{|r| if r < 0x100 ascOut.concat(r.chr) else ascOut.concat(sprintf("&#x%x;", r)) end } puts ascOut
Reads text, substituting entities
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]
Called before each event with line/column information.
Specifies the rdoc options to be used when generating API documentation.
Usage:
spec.rdoc_options << '--title' << 'Rake -- Ruby Make' << '--main' << 'README' << '--line-numbers'
Activate all unambiguously resolved runtime dependencies of this spec. Add any ambiguous dependencies to the unresolved list to be resolved later, as needed.
Sets rdoc_options
to value
, ensuring it is an array. Don’t use this, push onto the array instead.
List of dependencies that will automatically be activated at runtime.
Setter for the continue_timeout
attribute.
Iterates over each option, passing the option to the block
.
Add a command-line option and handler to the command.
See OptionParser#make_switch
for an explanation of opts
.
handler
will be called with two values, the value of the argument and the options hash.
If the first argument of add_option
is a Symbol
, it’s used to group options in output. See ‘gem help list` for an example.
Mark a command-line option as deprecated, and optionally specify a deprecation horizon.
Note that with the current implementation, every version of the option needs to be explicitly deprecated, so to deprecate an option defined as
add_option('-t', '--[no-]test', 'Set test mode') do |value, options| # ... stuff ... end
you would need to explicitly add a call to ‘deprecate_option` for every version of the option you want to deprecate, like
deprecate_option('-t') deprecate_option('--test') deprecate_option('--no-test')
Merge a set of command options with the set of default options (without modifying the default option hash).