class Slaw::Grammars::Schedules::LegacyScheduleTitle

Public Instance Methods

heading_plain_text() click to toggle source
# File lib/slaw/grammars/schedules_nodes.rb, line 48
def heading_plain_text
  heading.elements
    .select { |x| x.instance_of? ::Slaw::Grammars::Inlines::InlineItem }
    .map { |x| x.text_value }
    .join('')
    .strip
end
heading_text() click to toggle source
# File lib/slaw/grammars/schedules_nodes.rb, line 56
def heading_text
  if heading.empty?
    nil
  else
    text = self.heading_plain_text

    # change legacy titles that are just numbers (eg. the "1" in "Schedule 1")
    # to "Schedule 1"
    text = "Schedule #{text}" if /^\d+$/.match?(text)

    text
  end
end
to_xml(b, idprefix=nil, heading_text) click to toggle source
# File lib/slaw/grammars/schedules_nodes.rb, line 70
def to_xml(b, idprefix=nil, heading_text)
  if not heading.empty? and not (/^\d+$/.match?(self.heading_plain_text))
    b.heading { |b| heading.to_xml(b, idprefix) }
  else
    b.heading(heading_text)
  end

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