Class: Slaw::Grammars::ZA::Act::Subpart

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/slaw/grammars/za/act_nodes.rb

Instance Method Summary collapse

Instance Method Details

#numObject



166
167
168
# File 'lib/slaw/grammars/za/act_nodes.rb', line 166

def num
  heading.num
end

#to_xml(b, id_prefix = '', *args) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/slaw/grammars/za/act_nodes.rb', line 170

def to_xml(b, id_prefix='', *args)
  num = self.num
  if num.empty?
    num = Slaw::Grammars::Counters.counters[id_prefix]['subpart'] += 1
  else
    num = Slaw::Grammars::Counters.clean(num)
  end

  id = id_prefix + "subpart_#{num}"

  b.subpart(eId: id) { |b|
    heading.to_xml(b)
    children.elements.each_with_index { |e, i| e.to_xml(b, id + '__', i) }
  }
end