Class: Markdoc::Pseudocode::IfLiteral

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

Instance Method Summary collapse

Instance Method Details

#endsObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/markdoc/pseudocode.rb', line 52

def ends
  ary = []
  ary << if yes.elements.empty?
           yes.id
         else
           yes.elements.last.ends
         end
  ary << if no.elements.empty?
           no.id
         else
           no.elements.last.ends
         end
  ary.flatten
end

#idObject



48
49
50
# File 'lib/markdoc/pseudocode.rb', line 48

def id
  cond.id
end

#out(file) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/markdoc/pseudocode.rb', line 35

def out(file)
  file.write %(#{id} [shape=diamond label="#{cond.value}"]\n)

  unless yes.nil?
    yes.out(file)
    file.write %(  #{id} -> #{yes.id} [label="Yes"]\n)
  end
  unless no.nil?
    no.out(file)
    file.write %(  #{id} -> #{no.id} [label="No"]\n)
  end
end