Class: Slaw::Grammars::Schedules::ScheduleTitle

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

Instance Method Summary collapse

Instance Method Details

#heading_textObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/slaw/grammars/schedules_nodes.rb', line 22

def heading_text
  if heading.empty? or heading.title.empty?
    nil
  else
    heading.title.elements
      .select { |x| x.instance_of? ::Slaw::Grammars::Inlines::InlineItem }
      .map { |x| x.text_value }
      .join('')
      .strip
  end
end

#to_xml(b, idprefix = nil, heading_text) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/slaw/grammars/schedules_nodes.rb', line 34

def to_xml(b, idprefix=nil, heading_text)
  if not heading.empty? and not heading.title.empty?
    b.heading { |b| heading.title.to_xml(b, idprefix) }
  else
    b.heading(heading_text)
  end

  if not subheading.empty? and not subheading.title.empty?
    b.subheading { |b| subheading.title.to_xml(b, idprefix) }
  end
end