class Interscript::Node::Group
Attributes
children[RW]
reverse_run[RW]
Public Class Methods
new(reverse_run: nil)
click to toggle source
# File lib/interscript/node/group.rb, line 4 def initialize(reverse_run: nil) @reverse_run = reverse_run @children = [] end
Public Instance Methods
==(other)
click to toggle source
Calls superclass method
Interscript::Node#==
# File lib/interscript/node/group.rb, line 35 def ==(other) super && self.children == other.children && self.reverse_run == other.reverse_run end
apply_order(order)
click to toggle source
# File lib/interscript/node/group.rb, line 14 def apply_order(order) children_new = [nil] * @children.size order.each_with_index do |pos,idx| children_new[idx] = @children[pos] end @children = children_new #@children[source], @children[target] = @children[target], @children[source] self end
inspect()
click to toggle source
# File lib/interscript/node/group.rb, line 39 def inspect @children.map(&:inspect).join("\n").gsub(/^/, " ") end
reorder_children(source,target)
click to toggle source
# File lib/interscript/node/group.rb, line 9 def reorder_children(source,target) @children[source], @children[target] = @children[target], @children[source] self end
reverse()
click to toggle source
# File lib/interscript/node/group.rb, line 24 def reverse self.class.new(reverse_run: reverse_run.nil? ? nil : !reverse_run).tap do |r| r.children = self.children.reverse.map(&:reverse) end end
to_hash()
click to toggle source
# File lib/interscript/node/group.rb, line 30 def to_hash { :class => self.class.to_s, :children => @children.map{|x| x.to_hash} } end
to_visualization_array(map=self)
click to toggle source
# File lib/interscript/visualize/json.rb, line 2 def to_visualization_array(map=self) out = [] self.children.each do |rule| case rule when Interscript::Node::Rule::Sub more = [] more << "before: #{rule.before.to_html(map)}" if rule.before more << "after: #{rule.after.to_html(map)}" if rule.after more << "<nobr>not before:</nobr> #{rule.not_before.to_html(map)}" if rule.not_before more << "<nobr>not after:</nobr> #{rule.not_after.to_html(map)}" if rule.not_after more << "<nobr>reverse run:</nobr> #{rule.reverse_run}" unless rule.reverse_run.nil? more = more.join(", ") out << { type: "Replace", from: rule.from.to_html(map), to: Symbol === rule.to ? rule.to : rule.to.to_html(map), more: more } when Interscript::Node::Group::Parallel out << { type: "Parallel", children: rule.to_visualization_array(map) } when Interscript::Node::Rule::Funcall more = rule.kwargs.map do |k,v| "#{k.to_s.gsub("_", " ")}: #{v}" end more << "<nobr>reverse run:</nobr> #{rule.reverse_run}" unless rule.reverse_run.nil? out << { type: rule.name.to_s.gsub("_", " ").gsub(/^(.)/, &:upcase), more: more.join(", ") } when Interscript::Node::Rule::Run if rule.stage.map doc = map.dep_aliases[rule.stage.map].document stage = rule.stage.name else doc = map stage = rule.stage.name end more = [] more << "<nobr>reverse run:</nobr> #{rule.reverse_run}" unless rule.reverse_run.nil? out << { type: "Run", doc: doc.name, stage: stage, more: more.join(", "), } else out << { type: "Unknown", more: "<pre>#{h rule.inspect}</pre>" } end end out end