Class: Marvi::Diagram::SequenceRenderer
- Inherits:
-
Object
- Object
- Marvi::Diagram::SequenceRenderer
- Includes:
- BoxDrawing
- Defined in:
- lib/marvi/diagram.rb
Overview
Renders ‘sequenceDiagram` participants, lifelines and messages.
Constant Summary collapse
- PARTICIPANT_GAP =
4
Constants included from BoxDrawing
Instance Method Summary collapse
-
#initialize(lines, max_width) ⇒ SequenceRenderer
constructor
A new instance of SequenceRenderer.
- #render ⇒ Object
Methods included from BoxDrawing
Constructor Details
#initialize(lines, max_width) ⇒ SequenceRenderer
Returns a new instance of SequenceRenderer.
362 363 364 365 366 367 |
# File 'lib/marvi/diagram.rb', line 362 def initialize(lines, max_width) @lines = lines @max_width = max_width @participants = [] @messages = [] end |
Instance Method Details
#render ⇒ Object
369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/marvi/diagram.rb', line 369 def render return nil unless parse return nil if @participants.empty? || @messages.empty? grid = layout spans = grid.to_spans return nil if spans.empty? return nil if spans.any? { |line| Unicode::DisplayWidth.of(line.first.text) > @max_width } spans end |