Class: GraphDrawerFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/graphviz/graph_drawer_factory.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ GraphDrawerFactory

Returns a new instance of GraphDrawerFactory.



9
10
11
# File 'lib/generators/graphviz/graph_drawer_factory.rb', line 9

def initialize(config)
  @config = config
end

Instance Method Details

#create_drawer(node) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/graphviz/graph_drawer_factory.rb', line 13

def create_drawer(node)
  drawer = EmptyDrawer
  if node.function?
    drawer = FunctionLeafDrawer
  elsif node.folder?
    drawer = CollectionDrawer
    if node.level == @config[:levels]
      drawer = FolderLeafDrawer
    end
    unless @config[:folders]
      drawer = EmptyCollectionDrawer
    end
  elsif node.file? and @config[:files]
    drawer = (node.level == @config[:levels] or !@config[:functions]) ?
      FileLeafDrawer : CollectionDrawer
  end
  if @config[:root] and @config[:root] != node.path and
    (node.path.index(@config[:root]) == nil or
    @config[:root].index(node.path))
    drawer = node.function? ? EmptyDrawer : EmptyCollectionDrawer
  end
  drawer.new node, @config, self
end