Sha256: c38b4f78be4dd5e15fc5052b5356f31c060c8325ee0d3cfcbd608049dc9e92f8

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 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 Node
    include Constants
    @xNodeName
    @oAttrNode

    def initialize( xNodeName )
      @xNodeName = xNodeName
      @oAttrNode = GraphViz::Attrs::new( nil, "node", NODESATTRS )
    end

    def name
	    @xNodeName.clone
	  end
	
    def []=( xAttrName, xAttrValue )
      @oAttrNode[xAttrName.to_s] = xAttrValue
    end

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

    def output
      xOut = "" << @xNodeName.clone
      xAttr = ""
      xSeparator = ""
      @oAttrNode.data.each do |k, v|
	      if k == "html"
		      xAttr << xSeparator + "label = <" + v + ">"
		    else
          xAttr << xSeparator + k + " = \"" + v + "\""
		    end
        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/node.rb
ruby-graphviz-0.8.0 lib/graphviz/node.rb