In Files

Parent

Files

Class Index [+]

Quicksearch

Wdot

Wdot class - definitions checked:

Constants

Word_pat

Pattern to isolate words in a line - used by Wdot.split.

Head_pat

Pattern to match :head tag.

Node_pat

Pattern - node definition.

Start_node_pat

Pattern - start_node definition eg. _begin The parse pattern is almost the same - just different capture groups.

If_node_pat

if_node pattern.

Edge_pat

edge pattern: Node_pat -> Node_pat rest Groups: a->b “title” 1: a->b 2: a 3: -> 4: b 5: title

Public Class Methods

definition?(pat,line) click to toggle source

Is line a definition, given pat?

     # File wdot.rb, line 323
323:   def Wdot.definition?(pat,line)
324:     ret = false
325:     if line.match pat
326:       ret = true
327:     end
328:     return ret
329:   end
edge_parse(line) click to toggle source

Parse an edge definition. eg a->b “A to B“

     # File wdot.rb, line 288
288:   def Wdot.edge_parse(line)
289:     line.match Edge_pat
290:     edge_def=$1
291:     a = $2
292:     op = $3 if $3
293:     b = $4
294:     title = $5 if $5
295:     parse_string = ''
296:     if    op == '<-'
297:       parse_string = %{#{a}->#{b} [label="#{title}" dir="back"]\n}
298:     elsif op == '--'
299:       parse_string = %{#{a}->#{b} [label="#{title}" dir="none"]\n}
300:     elsif op == '<->'
301:       parse_string = %{#{a}->#{b} [label="#{title}" dir="both"]\n}
302:     elsif op == '-<'
303:       parse_string = %{#{a}->#{b} [label="#{title}" arrowhead="crow"]\n}
304:     elsif op == '>-'
305:       parse_string = %{#{a}->#{b} [label="#{title}" arrowtail="crow" arrowhead="none"]\n}
306:     else # -> case
307:       parse_string = %{#{a}->#{b} [label="#{title}"]\n}
308:     end
309:   end
head_parse(line) click to toggle source

Parse the :head tag

     # File wdot.rb, line 239
239:   def Wdot.head_parse(line)
240:     title = ''
241:     line.match Head_pat
242:     if $1.strip != ''
243:       ret = Wdot.split($1)
244:       ret.each { |e|
245:         if e =~ /^"?(TB|BT|RL|LR)"?$/
246:           @@rankdir = $1
247:         #elsif e =~ /^"?([-,\s\w]+)"?$/
248:         elsif e =~ /^(?:(?:"((?:[^"\\]*["\\]*)*)")*)$/
249:           title = $1
250:         end
251:       }
252:     end
253:     parse_string = digraph G {  graph [ label="#{title}", bgcolor="#{@@graph_bgcolor}",    fontname="#{@@graph_fontname}", rankdir="#{@@rankdir}"]  node [fontname="#{@@node_fontname}", shape="#{@@node_shape}",    style="#{@@node_style}", fillcolor="#{@@node_fillcolor}"]  edge [fontname="#{@@edge_fontname}", color="#{@@edge_color}",    dir="#{@@edge_dir}"]
254:   end
if_node_parse(line) click to toggle source

Parse an if_node. eg. if_ok

     # File wdot.rb, line 312
312:   def Wdot.if_node_parse(line)
313:     line.match If_node_pat
314:     node_name=$1
315:     title = "#{$2}?"
316:     title = $3 if $3
317:     parse_string = #{node_name} [label="#{title}",shape="diamond"]
318:   end
node_parse(line) click to toggle source

Parse a node definition.

     # File wdot.rb, line 277
277:   def Wdot.node_parse(line)
278:     line.match Node_pat
279:     node_name = $1
280:     title = $1
281:     title = $2 if $2
282:     parse_string = #{node_name} [label="#{title}"]
283:   end
split(line) click to toggle source

Split a string delimited by space of comma but keep quoted values together. Wdot.split ‘a “b,c”’ # -> [‘a’,’“b,c”’]

     # File wdot.rb, line 234
234:   def Wdot.split(line)
235:     line.scan Word_pat if line
236:   end
start_node_parse(line) click to toggle source

Parse start nodes eg. _begin or _end .

     # File wdot.rb, line 265
265:   def Wdot.start_node_parse(line)
266:     line.match Start_node_pat
267:     full_node_name = $1
268:     node_name = $2
269:     node_name = $3 if $3
270:     parse_string = #{full_node_name} [label="#{node_name}", shape="#{@@start_node_shape}",  fillcolor="#{@@start_node_fillcolor}"]
271:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.