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



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/slaw/za/act_nodes.rb', line 236

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
          blocklist.to_xml(b, idprefix, i) { |b| b << statement.content.text_value }
        else
          blocklist.to_xml(b, idprefix, i)
        end
      else
        # raw content
        statement.to_xml(b, idprefix)
      end
    }
  }
end