Class: Vertex

Inherits:
Object
  • Object
show all
Defined in:
lib/vertex.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Vertex

Returns a new instance of Vertex.



2
3
4
5
6
# File 'lib/vertex.rb', line 2

def initialize(name)
  @name = name
  @children = []
  @parents = []
end

Instance Method Details

#add_child(name) ⇒ Object



8
9
10
# File 'lib/vertex.rb', line 8

def add_child(name)
  @children << name
end

#add_parent(name) ⇒ Object



12
13
14
# File 'lib/vertex.rb', line 12

def add_parent(name)
  @parents << name
end

#childrenObject



20
21
22
# File 'lib/vertex.rb', line 20

def children
  @children
end

#nameObject



16
17
18
# File 'lib/vertex.rb', line 16

def name
  @name
end

#parentsObject



24
25
26
# File 'lib/vertex.rb', line 24

def parents
  @parents
end

#root?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/vertex.rb', line 28

def root?
  @parents.empty?
end