Class: Slaw::Grammars::Schedules::LegacyScheduleTitle
- Inherits:
-
Treetop::Runtime::SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- Slaw::Grammars::Schedules::LegacyScheduleTitle
- Defined in:
- lib/slaw/grammars/schedules_nodes.rb
Instance Method Summary collapse
- #heading_plain_text ⇒ Object
- #heading_text ⇒ Object
- #to_xml(b, idprefix = nil, heading_text) ⇒ Object
Instance Method Details
#heading_plain_text ⇒ Object
48 49 50 51 52 53 54 |
# 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 ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# 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) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 |
# 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 |