Class: Slaw::ZA::Act::Part

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

Instance Method Summary collapse

Instance Method Details

#numObject



95
96
97
# File 'lib/slaw/za/act_nodes.rb', line 95

def num
  heading.empty? ? nil : heading.num
end

#to_xml(b) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/slaw/za/act_nodes.rb', line 99

def to_xml(b)
  # do we have a part heading?
  if not heading.empty?
    id = "part-#{num}"

    # include a chapter number in the id if our parent has one
    if parent and parent.parent.is_a?(Chapter) and parent.parent.num
      id = "chapter-#{parent.parent.num}.#{id}"
    end

    b.part(id: id) { |b|
      heading.to_xml(b)
      sections.elements.each { |e| e.to_xml(b) }
    }
  else
    # no parts
    sections.elements.each { |e| e.to_xml(b) }
  end
end