Class: SimpleHdGraph::Renderer::PlantUML::Context
- Inherits:
-
Object
- Object
- SimpleHdGraph::Renderer::PlantUML::Context
- Defined in:
- lib/simple-hd-graph/renderer/plantuml/context.rb
Instance Method Summary collapse
- #indent_resource(resource) ⇒ String
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #render(node) ⇒ Object
-
#render_depends(depending) ⇒ String
:reek:UtilityFunction.
-
#render_relation(relation) ⇒ String
:reek:UtilityFunction.
Constructor Details
Instance Method Details
#indent_resource(resource) ⇒ String
45 46 47 48 49 |
# File 'lib/simple-hd-graph/renderer/plantuml/context.rb', line 45 def indent_resource(resource) @resource_renderer.render(resource).lines.map { |line| " #{line}" }.join end |
#render(node) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/simple-hd-graph/renderer/plantuml/context.rb', line 12 def render(node) resources = if node.resources.size > 0 node.resources.map { |resource| indent_resource(resource) }.join end relations = if node.relations.size > 0 node.relations.map { |relation| render_relation(relation) }.join("\n") end depends = if node.depends.size > 0 node.depends.map { |depending| render_depends(depending) }.join("\n") end <<~EOD.gsub(/^$\n/, "") rectangle "#{node.alias}" as #{node.id} { #{resources} #{relations} } #{depends} EOD end |
#render_depends(depending) ⇒ String
:reek:UtilityFunction
66 67 68 69 |
# File 'lib/simple-hd-graph/renderer/plantuml/context.rb', line 66 def render_depends(depending) depender, dependee = depending.to_a.first "#{depender} -|> #{dependee}" end |
#render_relation(relation) ⇒ String
:reek:UtilityFunction
56 57 58 59 |
# File 'lib/simple-hd-graph/renderer/plantuml/context.rb', line 56 def render_relation(relation) depender, dependee = relation.to_a.first " #{depender} -d-|> #{dependee}" end |