Class: RuTu::ValueNode
- Inherits:
-
Object
show all
- Defined in:
- lib/RuTu.rb
Instance Method Summary
collapse
Constructor Details
#initialize(g, v) ⇒ ValueNode
Returns a new instance of ValueNode.
8
9
10
11
|
# File 'lib/RuTu.rb', line 8
def initialize(g, v)
@graph = g
@value = v
end
|
Instance Method Details
#_obj_id ⇒ Object
15
16
17
|
# File 'lib/RuTu.rb', line 15
def _obj_id
RuTuExt._obj_id(@value)
end
|
#color ⇒ Object
33
34
35
|
# File 'lib/RuTu.rb', line 33
def color
"black"
end
|
#fields ⇒ Object
27
28
29
|
# File 'lib/RuTu.rb', line 27
def fields
[ :header ]
end
|
30
31
32
|
# File 'lib/RuTu.rb', line 30
def
[ self.class.name.gsub(/.*::/, ''), _obj_id() ]
end
|
#node_id ⇒ Object
24
25
26
|
# File 'lib/RuTu.rb', line 24
def node_id
"node#{ _obj_id() }"
end
|
#same_value?(v) ⇒ Boolean
12
13
14
|
# File 'lib/RuTu.rb', line 12
def same_value?(v)
RuTuExt._equal?(@value, v)
end
|
#to_dot ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/RuTu.rb', line 36
def to_dot
label = fields().map do |f|
v = self.respond_to?("#{f}_value") ? self.send("#{f}_value") : f
v = [ v ].flatten.map { |x| CGI.escapeHTML(x.to_s()) }.join("<br/>")
%Q! <tr><td port="#{f}">#{v}</td></tr> !
end.join(" ")
label = "<table>#{label}</table>"
node_id() + " [ shape=plaintext, color=#{color()}, label=<#{label}> ]"
end
|
#walk(new_value, node_class, relation) ⇒ Object
18
19
20
21
22
|
# File 'lib/RuTu.rb', line 18
def walk(new_value, node_class, relation)
n = @graph.add(new_value, node_class)
@graph.add_edge(self, n, relation)
n
end
|