Class: Slaw::Grammars::PL::Act::BlockWithIntroAndChildren

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

Direct Known Subclasses

Article, Litera, Paragraph, Point, Section

Instance Method Summary collapse

Instance Method Details

#intro_and_children_xml(b, idprefix) ⇒ Object



207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/slaw/grammars/pl/act_nodes.rb', line 207

def intro_and_children_xml(b, idprefix)
  if intro_node and !intro_node.empty?
    if not children.empty?
      b.intro { |b| intro_node.to_xml(b, idprefix) }
    else
      b.content { |b| intro_node.to_xml(b, idprefix) }
    end
  elsif children.empty?
    b.content { |b| b.p }
  end

  children.elements.each_with_index { |e, i| e.to_xml(b, idprefix, i) }
end

#intro_nodeObject



195
196
197
198
199
200
201
202
203
204
205
# File 'lib/slaw/grammars/pl/act_nodes.rb', line 195

def intro_node
  if intro.elements.length >= 1
    el = intro.elements[0]

    if el.respond_to? :intro_inline
      el.intro_inline
    elsif el.respond_to? :intro_block
      el.intro_block
    end
  end
end