Class: Hanuman::Graphvizzer::Node
- Inherits:
-
Item
- Object
- Item
- Hanuman::Graphvizzer::Node
show all
- Defined in:
- lib/hanuman/graphvizzer/gv_models.rb
Instance Method Summary
collapse
Methods inherited from Item
#attrib, #brace, #close_brace, #depth, #indent, #line, #quote
Instance Method Details
#abbreviate(word) ⇒ Object
120
121
122
123
124
125
|
# File 'lib/hanuman/graphvizzer/gv_models.rb', line 120
def abbreviate(word)
word.to_s.
gsub(/-\d+$/,''). split(/[\W_]+/). reject(&:empty?).map{|str| str[0] }.join
end
|
#inslots_str ⇒ Object
127
128
129
|
# File 'lib/hanuman/graphvizzer/gv_models.rb', line 127
def inslots_str
inslots.map{|slot| "<#{slot}>#{abbreviate(slot)}"}.join("|")
end
|
#label ⇒ Object
135
136
137
|
# File 'lib/hanuman/graphvizzer/gv_models.rb', line 135
def label
super.to_s.gsub(/_\d+$/, '').gsub(/[_\.]+/, "\\n")
end
|
#outslots_str ⇒ Object
131
132
133
|
# File 'lib/hanuman/graphvizzer/gv_models.rb', line 131
def outslots_str
outslots.map{|slot| "<_#{slot}>#{abbreviate(slot)}"}.join("|")
end
|
#structured_label ⇒ Object
139
140
141
142
143
144
145
146
147
|
# File 'lib/hanuman/graphvizzer/gv_models.rb', line 139
def structured_label
return label unless shape =~ /record/
str = "{"
str << "{" << (inslots.empty? ? "<i>" : inslots_str) << "}|"
str << label
str << "|{" << (outslots.empty? ? "<_o>" : outslots_str) << "}"
str << "}"
str
end
|
#to_s ⇒ Object
112
113
114
115
116
117
118
|
# File 'lib/hanuman/graphvizzer/gv_models.rb', line 112
def to_s
line(
quote(name), :shape => shape, :label => quote(structured_label), ) end
|