438: def initialize( xGraphName, *hOpt, &block )
439: @filename = nil
440: @name = xGraphName
441: @format = @@format
442: @prog = @@prog
443: @path = @@path
444:
445: @elements_order = Array::new()
446:
447: @oParentGraph = nil
448: @oGraphType = "digraph"
449:
450: @hoNodes = Hash::new()
451: @loEdges = Array::new()
452: @hoGraphs = Hash::new()
453:
454: @node = GraphViz::Attrs::new( self, "node", NODESATTRS )
455: @edge = GraphViz::Attrs::new( self, "edge", EDGESATTRS )
456: @graph = GraphViz::Attrs::new( self, "graph", GRAPHSATTRS )
457:
458: if hOpt.nil? == false and hOpt[0].nil? == false
459: hOpt[0].each do |xKey, xValue|
460: case xKey.to_s
461: when "output"
462: if FORMATS.index( xValue ).nil? == true
463: raise ArgumentError, "output format '#{xValue}' invalid"
464: end
465: @format = xValue
466: when "use"
467: if PROGRAMS.index( xValue ).nil? == true
468: raise ArgumentError, "can't use '#{xValue}'"
469: end
470: @prog = xValue
471: when "file"
472: @filename = xValue
473: when "parent"
474: @oParentGraph = xValue
475: when "type"
476: if GRAPHTYPE.index( xValue ).nil? == true
477: raise ArgumentError, "graph type '#{xValue}' unknow"
478: end
479: @oGraphType = xValue
480: when "path"
481: @path = xValue
482: else
483: self[xKey.to_s] = xValue
484: end
485: end
486: end
487:
488: yield( self ) if( block )
489: end