### Home Classes Methods

### In Files

- lib/graphviz/node.rb

### Parent

Object

### Methods

- ::new
- #-
- #<<
- #>
- #>>
- #[]
- #[]=
- #each_attribut
- #id
- #index
- #name
- #root_graph
- #set

### Included Modules

- Constants

### Files

- AUTHORS
- COPYING
- README.rdoc

### Class/Module Index

Quicksearch

- GraphViz
- GraphViz::Attrs
- GraphViz::Edge
- GraphViz::Elements
- GraphViz::Ext
- GraphViz::FamilyTree
- GraphViz::FamilyTree::Couple
- GraphViz::FamilyTree::Generation
- GraphViz::FamilyTree::Person
- GraphViz::FamilyTree::Sibling
- GraphViz::GraphML
- GraphViz::Math
- GraphViz::Math::CoordinateError
- GraphViz::Math::Matrix
- GraphViz::Math::ValueError
- GraphViz::Node
- GraphViz::Theory
- GraphViz::Types
- GraphViz::Types::Common
- GraphViz::Types::EscString
- GraphViz::Types::GvDouble
- GraphViz::Types::HtmlString
- GraphViz::Types::LblString
- GraphViz::XML
- Constants
- GVUtils
- Hash
- Object
- String

No matching classes.

# GraphViz::Node

### Public Class Methods

new( xNodeName, oGParrent ) click to toggle source

Create a new node

In:

- xNodeName : ID of the node

- oGParrent : Graph

    # File lib/graphviz/node.rb, line 34
    def initialize( xNodeName, oGParrent )
      @xNodeName = xNodeName
      @oGParrent = oGParrent
      @oAttrNode = GraphViz::Attrs::new( nil, "node", NODESATTRS )
      @index = nil
    end

### Public Instance Methods

-( oNode ) click to toggle source
Alias for: <<
<<( oNode ) click to toggle source

Create an edge between the current node and the node `oNode`

    # File lib/graphviz/node.rb, line 114
    def <<( oNode )
      if( oNode.class == Array )
        oNode.each do |no|
          self << no
        end
      else
        return GraphViz::commonGraph( oNode, self ).add_edge( self, oNode )
      end
    end

Also aliased as: >, -, >>
>( oNode ) click to toggle source
Alias for: <<
>>( oNode ) click to toggle source
Alias for: <<
[]( xAttrName ) click to toggle source

Get the value of the node attribut `xAttrName`

    # File lib/graphviz/node.rb, line 85
    def []( xAttrName )
      if Hash === xAttrName
        xAttrName.each do |key, value|
          self[key] = value
        end
      else
        (@oAttrNode[xAttrName.to_s].nil?)?nil:@oAttrNode[xAttrName.to_s].clone
      end
    end

[]=( xAttrName, xAttrValue ) click to toggle source

Set value `xAttrValue` to the node attribut `xAttrName`

    # File lib/graphviz/node.rb, line 77
    def []=( xAttrName, xAttrValue )
      xAttrValue = xAttrValue.to_s if xAttrValue.class == Symbol
      @oAttrNode[xAttrName.to_s] = xAttrValue
    end

each_attribut(global = true, &b) click to toggle source

Calls block once for each attribut of the node, passing the name and value to the block as a two-element array.

If global is set to false, the block does not receive the attributs set globally

    # File lib/graphviz/node.rb, line 101
    def each_attribut(global = true, &b)
      attrs = @oAttrNode.to_h
      if global
        attrs = pg.node.to_h.merge attrs
      end
      attrs.each do |k,v|
        yield(k,v)
      end
    end

id() click to toggle source

Get the node ID

    # File lib/graphviz/node.rb, line 53
    def id
            @xNodeName.clone
          end

index() click to toggle source

Return the node index

    # File lib/graphviz/node.rb, line 60
          def index
            @index
    end

name() click to toggle source

Get the node ID

    # File lib/graphviz/node.rb, line 44
    def name
      # TODO : Remove in v1.0
            warn "GraphViz::Node#name is deprecated, please use GraphViz::Node#id! -- BE CAREFUL, it will be removed in the 1.0 version!"
            return self.id
          end

root_graph() click to toggle source

Return the root graph

    # File lib/graphviz/node.rb, line 70
    def root_graph
      return( (self.pg.nil?) ? nil : self.pg.root_graph )
    end

set( &b ) click to toggle source

Set node attributs

Example :

    n = graph.add_node( ... )
    ...
    n.set { |_n|
      _n.color = "blue"
      _n.fontcolor = "red"
    }

    # File lib/graphviz/node.rb, line 138
    def set( &b )
      yield( self )
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.