Class: Dogviz::System

Inherits:
Object
  • Object
show all
Includes:
Nominator, Parent
Defined in:
lib/dogviz/system.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Nominator

#nominate, #nominate_from

Methods included from Parent

#add, #container, #find, #find_all, #group, #logical_container, #root?, #thing

Constructor Details

#initialize(name, hints = {splines: 'line'}) ⇒ System

Returns a new instance of System.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dogviz/system.rb', line 15

def initialize(name, hints = {splines: 'line'})
  @children = []
  @by_name = Registry.new name
  @non_render_hints = remove_dogviz_hints!(hints)
  @render_hints = hints
  @title = create_title(name)
  @rendered = false
  
  @warnings = Set.new
  @messages = Set.new
  
  @suppress_warnings = false
  @suppress_messages = false
  
  on_exit {
    output_messages
    output_warnings
  }
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



10
11
12
# File 'lib/dogviz/system.rb', line 10

def children
  @children
end

#graphObject (readonly)

Returns the value of attribute graph.



10
11
12
# File 'lib/dogviz/system.rb', line 10

def graph
  @graph
end

#render_hintsObject (readonly) Also known as: render_options

Returns the value of attribute render_hints.



10
11
12
# File 'lib/dogviz/system.rb', line 10

def render_hints
  @render_hints
end

#titleObject (readonly) Also known as: name

Returns the value of attribute title.



10
11
12
# File 'lib/dogviz/system.rb', line 10

def title
  @title
end

Instance Method Details

#auto_nominate?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/dogviz/system.rb', line 87

def auto_nominate?
  @non_render_hints[:auto_nominate]
end

#colorize_edges?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/dogviz/system.rb', line 83

def colorize_edges?
  @non_render_hints[:colorize_edges]
end

#create_renderer(type) ⇒ Object



60
61
62
63
64
65
66
67
68
69
# File 'lib/dogviz/system.rb', line 60

def create_renderer(type)
  if type == :graphviz
    GraphvizRenderer.new @title, render_hints
  elsif type == :sigma
    SigmaRenderer.new @title
  else
    raise "dunno bout that '#{type}', only know :graphviz or :sigma"
  end

end

#flow(name) ⇒ Object



42
43
44
# File 'lib/dogviz/system.rb', line 42

def flow(name)
  Flow.new self, name
end

#messagesObject



99
100
101
# File 'lib/dogviz/system.rb', line 99

def messages
  @messages.to_a
end

#output(*args) ⇒ Object



35
36
37
38
39
40
# File 'lib/dogviz/system.rb', line 35

def output(*args)
  render
  out = graph.output(*args)
  @messages << "Created output: #{args.join ' '}" unless suppress_messages?
  out
end

#register(name, thing) ⇒ Object



79
80
81
# File 'lib/dogviz/system.rb', line 79

def register(name, thing)
  @by_name.register name, thing
end

#render(type = :graphviz) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/dogviz/system.rb', line 46

def render(type=:graphviz)
  return @graph if @rendered
  renderer = create_renderer(type)

  children.each { |c|
    c.render renderer
  }
  children.each { |c|
    c.render_edges renderer
  }
  @rendered = true
  @graph = renderer.graph
end

#rollup?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/dogviz/system.rb', line 71

def rollup?
  false
end

#skip?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/dogviz/system.rb', line 75

def skip?
  false
end

#suppress_messages!Object



108
109
110
111
# File 'lib/dogviz/system.rb', line 108

def suppress_messages!
  @suppress_messages = true
  self
end

#suppress_warnings!Object



103
104
105
106
# File 'lib/dogviz/system.rb', line 103

def suppress_warnings!
  @suppress_warnings = true
  self
end

#warn_on_exit(warning) ⇒ Object



91
92
93
# File 'lib/dogviz/system.rb', line 91

def warn_on_exit(warning)
  @warnings << warning
end

#warningsObject



95
96
97
# File 'lib/dogviz/system.rb', line 95

def warnings
  @warnings.to_a
end