### Home Classes Methods

### In Files

- lib/graphviz/family_tree.rb
- lib/graphviz/family_tree/generation.rb
- lib/graphviz/family_tree/person.rb
- lib/graphviz/family_tree/sibling.rb
- lib/graphviz/family_tree/couple.rb

### Parent

Object

### Namespace

- CLASS GraphViz::FamilyTree::Couple
- CLASS GraphViz::FamilyTree::Generation
- CLASS GraphViz::FamilyTree::Person
- CLASS GraphViz::FamilyTree::Sibling

### Methods

- ::new
- #couple
- #generation
- #graph
- #size

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

### Public Class Methods

new( &block ) click to toggle source

Create a new family tree

    require 'graphviz/family_tree'
    t = GraphViz::FamilyTree.new do
      ...
    end

    # File lib/graphviz/family_tree.rb, line 17
    def initialize( &block )
      @persons = {}
      @graph = GraphViz.new( "FamilyTree", :use => :neato )
      @generation_number = 0
      @generations = []
      @couples = {}

      instance_eval(&block) if block
    end

### Public Instance Methods

couple( x, y ) click to toggle source

Get a couple (GraphViz::FamilyTree::Couple)

    # File lib/graphviz/family_tree.rb, line 57
    def couple( x, y )
      @couples[x][y]
    end

generation( &b ) click to toggle source

Add a new generation in the tree

    require 'graphviz/family_tree'
    t = GraphViz::FamilyTree.new do
      generation do
        ...
      end
      generation do
        ...
      end
    end

    # File lib/graphviz/family_tree.rb, line 38
    def generation( &b )
      gen = GraphViz::FamilyTree::Generation.new( @graph, @persons, self, @generation_number )
      gen.make( &b )
      @generations << gen
      @generation_number += 1
    end

graph() click to toggle source

Get the graph

    # File lib/graphviz/family_tree.rb, line 71
    def graph
      maxY = @generations.size
      biggestGen, maxX = biggestGenerationNumberAndSize

      puts "#{maxY} generations"
      puts "Plus grosse generation : ##{biggestGen} avec #{maxX} personnes"

      puts "traitement des générations..."

      puts "  #{biggestGen}:"
      @generations[biggestGen].persons.each do |id, person|
        puts "    - #{id} : #{person.class}"
      end

      puts "  Up..."
      (0...biggestGen).reverse_each do |genNumber|
        puts "  #{genNumber}:"
        @generations[genNumber].persons.each do |id, person|
          puts "    - #{id} : #{person.class}"
        end
      end

      puts "  Down..."
      ((biggestGen+1)...maxY).each do |genNumber|
        puts "  #{genNumber}:"
        @generations[genNumber].persons.each do |id, person|
          puts "    - #{id} : #{person.class}"
        end
      end

      @graph
    end

size() click to toggle source

Family size

    # File lib/graphviz/family_tree.rb, line 66
    def size
      @persons.size
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.