600: def initialize( xGraphName, *hOpt, &block )
601: @filename = nil
602: @name = xGraphName.to_s
603: @format = @@format
604: @prog = @@prog
605: @path = @@path
606: @errors = @@errors
607: @extlibs = @@extlibs
608: @output = {}
609:
610: @elements_order = Array::new()
611:
612: @oParentGraph = nil
613: @oGraphType = "digraph"
614:
615: @hoNodes = Hash::new()
616: @loEdges = Array::new()
617: @hoGraphs = Hash::new()
618:
619: @node = GraphViz::Attrs::new( self, "node", NODESATTRS )
620: @edge = GraphViz::Attrs::new( self, "edge", EDGESATTRS )
621: @graph = GraphViz::Attrs::new( self, "graph", GRAPHSATTRS )
622:
623: if hOpt.nil? == false and hOpt[0].nil? == false
624: hOpt[0].each do |xKey, xValue|
625: case xKey.to_s
626: when "output"
627: warn ":output option is deprecated, please use :<format> => :<file>"
628: if FORMATS.index( xValue.to_s ).nil? == true
629: raise ArgumentError, "output format '#{xValue}' invalid"
630: end
631: @format = xValue.to_s
632: when "use"
633: if PROGRAMS.index( xValue.to_s ).nil? == true
634: raise ArgumentError, "can't use '#{xValue}'"
635: end
636: @prog = xValue.to_s
637: when "file"
638: warn ":file option is deprecated, please use :<format> => :<file>"
639: @filename = xValue.to_s
640: when "parent"
641: @oParentGraph = xValue
642: when "type"
643: if GRAPHTYPE.index( xValue.to_s ).nil? == true
644: raise ArgumentError, "graph type '#{xValue}' unknow"
645: end
646: @oGraphType = xValue.to_s
647: when "path"
648: @path = xValue.split( "," ).map{ |x| x.strip }
649: when "errors"
650: @errors = xValue
651: when "extlibs"
652: @extlibs = xValue.split( "," ).map{ |x| x.strip }
653: else
654: self[xKey.to_s] = xValue.to_s
655: end
656: end
657: end
658:
659: yield( self ) if( block )
660: end