Class: Dogviz::SigmaRenderer
- Inherits:
-
Object
- Object
- Dogviz::SigmaRenderer
- Defined in:
- lib/dogviz/sigma_renderer.rb
Instance Method Summary collapse
- #graph ⇒ Object
-
#initialize(title) ⇒ SigmaRenderer
constructor
A new instance of SigmaRenderer.
- #render_edge(from, to, options) ⇒ Object
- #render_node(parent, id, attributes) ⇒ Object
- #render_subgraph(parent, id, attributes) ⇒ Object
Constructor Details
#initialize(title) ⇒ SigmaRenderer
Returns a new instance of SigmaRenderer.
5 6 7 8 9 |
# File 'lib/dogviz/sigma_renderer.rb', line 5 def initialize(title) @title = title @nodes = [] @edges = [] end |
Instance Method Details
#graph ⇒ Object
11 12 13 |
# File 'lib/dogviz/sigma_renderer.rb', line 11 def graph SigmaGraphHash.new(nodes: nodes, edges: edges) end |
#render_edge(from, to, options) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/dogviz/sigma_renderer.rb', line 25 def render_edge(from, to, ) @edges << { id: "#{from.id}->#{to.id}", label: "#{from.id}->#{to.id}", source: from.id, target: to.id } end |
#render_node(parent, id, attributes) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/dogviz/sigma_renderer.rb', line 15 def render_node(parent, id, attributes) @nodes << {id: id, label: id} @edges << { id: "#{parent.id}->#{id}", type: 'containment', source: parent.id, target: id } unless parent.root? end |
#render_subgraph(parent, id, attributes) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/dogviz/sigma_renderer.rb', line 34 def render_subgraph(parent, id, attributes) @nodes << {id: container_label(id), type: 'container', label: container_label(id)} @edges << { id: "#{container_label parent.id}->#{container_label id}", type: 'containment', source: container_label(parent.id), target: container_label(id) } unless parent.root? end |