Class: Diagrams::VarGraph::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/maruku/ext/diagrams/layout.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_) ⇒ Node

Returns a new instance of Node.



30
31
32
33
34
35
36
# File 'lib/maruku/ext/diagrams/layout.rb', line 30

def initialize(name_) 
	@name = name_
	@children = []
	@parents = []
	@next = []
	@prev = []
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



24
25
26
# File 'lib/maruku/ext/diagrams/layout.rb', line 24

def children
  @children
end

#nameObject

Returns the value of attribute name.



23
24
25
# File 'lib/maruku/ext/diagrams/layout.rb', line 23

def name
  @name
end

#nextObject

closure of children



27
28
29
# File 'lib/maruku/ext/diagrams/layout.rb', line 27

def next
  @next
end

#parentsObject

Returns the value of attribute parents.



25
26
27
# File 'lib/maruku/ext/diagrams/layout.rb', line 25

def parents
  @parents
end

#prevObject

closure of parents



28
29
30
# File 'lib/maruku/ext/diagrams/layout.rb', line 28

def prev
  @prev
end

Instance Method Details

#compute_children_closureObject



52
53
54
55
56
57
58
59
60
# File 'lib/maruku/ext/diagrams/layout.rb', line 52

def compute_children_closure
	@children.each do |child| # xxx rifare
		child.compute_children_closure 
	end

	@next = @children.map do |c| c.next end.flatten
	@next += @children
	@next.uniq!
end

#compute_parents_closureObject

return parents



42
43
44
45
46
47
48
49
50
# File 'lib/maruku/ext/diagrams/layout.rb', line 42

def compute_parents_closure
	@parents.each do |parent| # xxx rifare
		parent.compute_parents_closure 
	end

	@prev = @parents.map do |p| p.prev end.flatten
	@prev += @parents
	@prev.uniq!
end

#dist_downObject



63
# File 'lib/maruku/ext/diagrams/layout.rb', line 63

def dist_down() @children.empty? ? 0 : @children.map{|x| x.dist_down}.max+1 end

#dist_upObject



62
# File 'lib/maruku/ext/diagrams/layout.rb', line 62

def dist_up() @parents.empty? ? 0 : @parents.map{|x| x.dist_up}.max+1 end

#inspectObject Also known as: to_s



38
# File 'lib/maruku/ext/diagrams/layout.rb', line 38

def inspect() "N[#{@name}]" end