Class: Statesman::Diagram
- Inherits:
-
Object
- Object
- Statesman::Diagram
- Defined in:
- lib/statesman/diagram.rb,
lib/statesman/diagram/version.rb
Constant Summary collapse
- VERSION =
'0.1.3'.freeze
Instance Method Summary collapse
-
#initialize(name:, graph:) ⇒ Diagram
constructor
A new instance of Diagram.
-
#to_dot ⇒ String
Diagram in DOT format.
- #to_png(file_name = nil) ⇒ Object
Constructor Details
#initialize(name:, graph:) ⇒ Diagram
Returns a new instance of Diagram.
7 8 9 10 |
# File 'lib/statesman/diagram.rb', line 7 def initialize(name:, graph:) @name = name @graph = graph end |
Instance Method Details
#to_dot ⇒ String
Returns diagram in DOT format.
13 14 15 |
# File 'lib/statesman/diagram.rb', line 13 def to_dot format("digraph %{name} {\n %{body}\n}", name: @name, body: dot_body.join("\n ")) end |
#to_png(file_name = nil) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/statesman/diagram.rb', line 17 def to_png(file_name = nil) file_name ||= @name file_name += '.png' build_png(file_name) end |