Class: Markdoc::Pseudocode::ExpressionLiteral

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/markdoc/pseudocode.rb

Instance Method Summary collapse

Instance Method Details

#endsObject



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/markdoc/pseudocode.rb', line 96

def ends
  ary = []
  elements.each do |node|
    ary << if node.elements.empty?
             node.id
           else
             node.ends
           end
  end
  ary.flatten
end

#idObject



92
93
94
# File 'lib/markdoc/pseudocode.rb', line 92

def id
  elements.first.id
end

#out(file) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/markdoc/pseudocode.rb', line 79

def out(file)
  prev = nil
  elements.each do |node|
    next if node.nil?

    node.out(file)
    prev&.ends&.each do |endid|
      file.write %(#{endid} -> #{node.id}\n)
    end
    prev = node
  end
end