Class: Slaw::ZA::Act::Subsection

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

Instance Method Summary collapse

Instance Method Details

#to_xml(b, idprefix, i = 0) ⇒ Object



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/slaw/za/act_nodes.rb', line 249

def to_xml(b, idprefix, i=0)
  if statement.is_a?(NumberedStatement)
    attribs = {id: idprefix + statement.num.gsub(/[()]/, '')}
  else
    attribs = {id: idprefix + "subsection-#{i}"}
  end

  idprefix = attribs[:id] + "."

  b.subsection(attribs) { |b|
    b.num(statement.num) if statement.is_a?(NumberedStatement)
    
    b.content { |b| 
      if blocklist and blocklist.is_a?(Blocklist)
        if statement.content
          # provide the statement as the list introduction to the block list
          blocklist.to_xml(b, idprefix, i) { |b| statement.content.to_xml(b, idprefix) }
        else
          blocklist.to_xml(b, idprefix, i)
        end
      else
        # raw content
        statement.to_xml(b, idprefix)
      end
    }
  }
end