lib/graphviz/xml.rb in ruby-graphviz-0.9.21 vs lib/graphviz/xml.rb in ruby-graphviz-1.0.0
- old
+ new
@@ -18,45 +18,33 @@
require 'rexml/document'
class GraphViz
class XML
- @oReXML
- @oGraph
- @xNodeName
- @bShowText
- @bShowAttrs
+ # The GraphViz object
+ attr_accessor :graph
#
# Generate the graph
#
- # Options :
- # * :output : Output format (Constants::FORMATS)
- # * :file : Output file name
- # * :use : Program to use (Constants::PROGRAMS)
- # * :path : Program PATH
- # * :<format> => <file> : <file> can be
- # * a file name
- # * nil, then the output will be printed to STDOUT
- # * String, then the output will be returned as a String
- # * :errors : DOT error level (default 1)
- # * 0 = Error + Warning
- # * 1 = Error
- # * 2 = none
+ # THIS METHOD IS DEPRECATED, PLEASE USE GraphViz::XML.graph.output
#
def output( *hOpt )
- @oGraph.output( *hOpt )
+ warn "GraphViz::XML.output is deprecated, use GraphViz::XML.graph.output"
+ @graph.output( *hOpt )
end
private
#
# Create a graph from a XML file
#
# In:
# * xFile : XML File
- # * *hOpt : Graph options
+ # * *hOpt : Graph options:
+ # * :text : show text nodes (default true)
+ # * :attrs : show XML attributs (default true)
#
def initialize( xFile, *hOpt )
@xNodeName = "00000"
@bShowText = true
@bShowAttrs = true
@@ -73,11 +61,11 @@
end
end
end
@oReXML = REXML::Document::new( File::new( xFile ) )
- @oGraph = GraphViz::new( "XML", *hOpt )
+ @graph = GraphViz::new( "XML", *hOpt )
_init( @oReXML.root() )
end
def _init( oXMLNode ) #:nodoc:
xLocalNodeName = @xNodeName.clone
@@ -91,11 +79,11 @@
label << "| { #{xName} | #{xValue} } "
end
label << "}"
end
- @oGraph.add_node( xLocalNodeName, "label" => label, "color" => "blue", "shape" => "record" )
+ @graph.add_node( xLocalNodeName, "label" => label, "color" => "blue", "shape" => "record" )
## Act: Search and add Text nodes
if oXMLNode.has_text? == true and @bShowText == true
xTextNodeName = xLocalNodeName.clone
xTextNodeName << "111"
@@ -109,20 +97,20 @@
xSep = "\n"
end
end
if xText.length > 0
- @oGraph.add_node( xTextNodeName, "label" => xText, "color" => "black", "shape" => "ellipse" )
- @oGraph.add_edge( xLocalNodeName, xTextNodeName )
+ @graph.add_node( xTextNodeName, "label" => xText, "color" => "black", "shape" => "ellipse" )
+ @graph.add_edge( xLocalNodeName, xTextNodeName )
end
end
## Act: Search and add attributs
## TODO
oXMLNode.each_element( ) do |oXMLChild|
xChildNodeName = _init( oXMLChild )
- @oGraph.add_edge( xLocalNodeName, xChildNodeName )
+ @graph.add_edge( xLocalNodeName, xChildNodeName )
end
return( xLocalNodeName )
end