### Home Classes Methods

### In Files

- lib/graphviz/elements.rb

### Parent

Object

### Methods

- ::new
- #[]
- #each
- #push
- #size_of

### 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::Elements

### Public Class Methods

new() click to toggle source

    # File lib/graphviz/elements.rb, line 3
    def initialize
      @elements = Array.new
      @elements_hash_by_type = Hash.new
    end

### Public Instance Methods

[]( index, type = nil ) click to toggle source

    # File lib/graphviz/elements.rb, line 31
    def []( index, type = nil )
      if type.nil?
        return @elements[index]
      else
        return @elements_hash_by_type[type][index]
      end
    end

each( &b ) click to toggle source

    # File lib/graphviz/elements.rb, line 17
    def each( &b )
      @elements.each do |e|
        yield( e )
      end
    end

push( obj ) click to toggle source

    # File lib/graphviz/elements.rb, line 8
    def push( obj )
      @elements.push( obj )
      if @elements_hash_by_type[obj['type']].nil?
        @elements_hash_by_type[obj['type']] = Array.new
      end

      @elements_hash_by_type[obj['type']].push( obj )
    end

size_of( type ) click to toggle source

    # File lib/graphviz/elements.rb, line 23
    def size_of( type )
      if @elements_hash_by_type[type].nil?
        return 0
      else
        return @elements_hash_by_type[type].size
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.