Class: GraphViz::FamilyTree::Person
- Inherits:
-
Object
- Object
- GraphViz::FamilyTree::Person
- Defined in:
- lib/graphviz/family_tree/person.rb
Instance Method Summary (collapse)
-
- (Object) couples
:nodoc:.
- - (Object) id
-
- (Person) initialize(graph, tree, generation, id)
constructor
:nodoc:.
-
- (Object) is_a_boy(name)
Define the current person as a boy.
-
- (Object) is_a_girl(name)
Define the current perdon as a girl.
-
- (Object) is_a_man(name)
Define the current person as a man.
-
- (Object) is_a_woman(name)
Define the current perdon as a woman.
-
- (Object) is_dead
Define the current person as dead.
-
- (Object) is_divorced_with(x)
Define that's two persons are divorced.
-
- (Object) is_maried_with(x)
Define that's two persons are maried.
-
- (Object) is_widower_of(x)
Define that's a person is widower of another.
-
- (Object) kids(*z)
Define the kids of a single person.
- - (Object) name
-
- (Object) node
:nodoc:.
- - (Object) sibling
- - (Object) sibling=(x)
Constructor Details
- (Person) initialize(graph, tree, generation, id)
:nodoc:
7 8 9 10 11 12 13 14 15 |
# File 'lib/graphviz/family_tree/person.rb', line 7 def initialize( graph, tree, generation, id ) #:nodoc: @graph = graph @node = @graph.add_nodes( id ) @node["shape"] = "box" @tree = tree @generation = generation @x, @y = 0, 0 @sibling = nil end |
Instance Method Details
- (Object) couples
:nodoc:
33 34 35 |
# File 'lib/graphviz/family_tree/person.rb', line 33 def couples #:nodoc: @couples end |
- (Object) id
17 18 19 |
# File 'lib/graphviz/family_tree/person.rb', line 17 def id @node.id end |
- (Object) is_a_boy(name)
Define the current person as a boy
greg.is_a_boy( "Greg" )
52 53 54 |
# File 'lib/graphviz/family_tree/person.rb', line 52 def is_a_boy( name ) is_a_man( name ) end |
- (Object) is_a_girl(name)
Define the current perdon as a girl
maia.is_a_girl( "Maia" )
66 67 68 |
# File 'lib/graphviz/family_tree/person.rb', line 66 def is_a_girl( name ) is_a_woman( name ) end |
- (Object) is_a_man(name)
Define the current person as a man
greg.is_a_man( "Greg" )
44 45 46 47 |
# File 'lib/graphviz/family_tree/person.rb', line 44 def is_a_man( name ) @node["label"] = name @node["color"] = "blue" end |
- (Object) is_a_woman(name)
Define the current perdon as a woman
mu.is_a_woman( "Muriel" )
59 60 61 62 |
# File 'lib/graphviz/family_tree/person.rb', line 59 def is_a_woman( name ) @node["label"] = name @node["color"] = "pink" end |
- (Object) is_dead
Define the current person as dead
jack.is_dead
108 109 110 |
# File 'lib/graphviz/family_tree/person.rb', line 108 def is_dead @node["style"] = "filled" end |
- (Object) is_divorced_with(x)
Define that's two persons are divorced
sophie.is_divorced_with john
84 85 86 87 88 89 90 91 |
# File 'lib/graphviz/family_tree/person.rb', line 84 def is_divorced_with( x ) node = @graph.add_nodes( "#{@node.id}And#{x.node.id}" ) node["shape"] = "point" node["color"] = "red" @graph.add_edges( @node, node, "dir" => "none", "color" => "red" ) @graph.add_edges( node, x.node, "dir" => "none", "color" => "red" ) @tree.add_couple( self, x, node ) end |
- (Object) is_maried_with(x)
Define that's two persons are maried
mu.is_maried_with greg
73 74 75 76 77 78 79 |
# File 'lib/graphviz/family_tree/person.rb', line 73 def is_maried_with( x ) node = @graph.add_nodes( "#{@node.id}And#{x.node.id}" ) node["shape"] = "point" @graph.add_edges( @node, node, "dir" => "none" ) @graph.add_edges( node, x.node, "dir" => "none" ) @tree.add_couple( self, x, node ) end |
- (Object) is_widower_of(x)
Define that's a person is widower of another
simon.is_widower_of elisa
96 97 98 99 100 101 102 103 |
# File 'lib/graphviz/family_tree/person.rb', line 96 def is_widower_of( x ) #veuf node = @graph.add_nodes( "#{@node.id}And#{x.node.id}" ) node["shape"] = "point" node["color"] = "green" @graph.add_edges( @node, node, "dir" => "none", "color" => "green" ) @graph.add_edges( node, x.node, "dir" => "none", "color" => "green" ) @tree.add_couple( self, x, node ) end |
- (Object) kids(*z)
Define the kids of a single person
alice.kids( john, jack, julie )
115 116 117 |
# File 'lib/graphviz/family_tree/person.rb', line 115 def kids( *z ) GraphViz::FamilyTree::Couple.new( @graph, @node, [self] ).kids( *z ) end |
- (Object) name
21 22 23 |
# File 'lib/graphviz/family_tree/person.rb', line 21 def name @node.label || @node.id end |
- (Object) node
:nodoc:
37 38 39 |
# File 'lib/graphviz/family_tree/person.rb', line 37 def node #:nodoc: @node end |
- (Object) sibling
25 26 27 |
# File 'lib/graphviz/family_tree/person.rb', line 25 def sibling @sibling end |
- (Object) sibling=(x)
29 30 31 |
# File 'lib/graphviz/family_tree/person.rb', line 29 def sibling=(x) @sibling=x end |