Sha256: 1276292288b6e0f62d6f70499078959b8d7bd37da1e88713e2eaafcc40356c3b

Contents?: true

Size: 1.86 KB

Versions: 2

Compression:

Stored size: 1.86 KB

Contents

# Copyright (C) 2004, 2005, 2006, 2007 Gregoire Lejeune <gregoire.lejeune@free.fr>
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

require 'graphviz/attrs'
require 'graphviz/constants'

class GraphViz
  class Edge
    include Constants
    @xNodeOne
    @xNodeTwo
    @oAttrEdge

    def initialize( vNodeOne, vNodeTwo )
	    if vNodeOne.class == String
        @xNodeOne = vNodeOne
	    else
        @xNodeOne = vNodeOne.name
	    end
	  
	    if vNodeTwo.class == String
        @xNodeTwo = vNodeTwo
	    else
        @xNodeTwo = vNodeTwo.name
	    end

      @oAttrEdge = GraphViz::Attrs::new( nil, "edge", EDGESATTRS )
    end

    def []=( xAttrName, xAttrValue )
      @oAttrEdge[xAttrName.to_s] = xAttrValue
    end

    def []( xAttrName )
      @oAttrEdge[xAttrName.to_s].clone
    end

	  def output( oGraphType )
	    xLink = " -> "
	    if oGraphType == "graph"
	      xLink = " -- "
	    end
	  
	    xOut = @xNodeOne + xLink + @xNodeTwo
      xAttr = ""
      xSeparator = ""
      @oAttrEdge.data.each do |k, v|
        xAttr << xSeparator + k + " = \"" + v + "\""
        xSeparator = ", "
      end
      if xAttr.length > 0
        xOut << " [" + xAttr + "]"
      end
      xOut + ";"

      return( xOut )
	  end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-graphviz-0.7.0 lib/graphviz/edge.rb
ruby-graphviz-0.8.0 lib/graphviz/edge.rb