Class: Ace::Bundle::Molecules::SectionFormatter
- Inherits:
-
Object
- Object
- Ace::Bundle::Molecules::SectionFormatter
- Defined in:
- lib/ace/bundle/molecules/section_formatter.rb
Overview
Formats sections with XML-style tags for different output formats
Instance Method Summary collapse
-
#format_sections_only(sections) ⇒ String
Formats only the sections part (for inclusion in larger documents).
-
#format_with_sections(bundle_data) ⇒ String
Formats bundle data with sections.
-
#initialize(format = "markdown-xml") ⇒ SectionFormatter
constructor
A new instance of SectionFormatter.
Constructor Details
#initialize(format = "markdown-xml") ⇒ SectionFormatter
Returns a new instance of SectionFormatter.
8 9 10 |
# File 'lib/ace/bundle/molecules/section_formatter.rb', line 8 def initialize(format = "markdown-xml") @format = format end |
Instance Method Details
#format_sections_only(sections) ⇒ String
Formats only the sections part (for inclusion in larger documents)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ace/bundle/molecules/section_formatter.rb', line 27 def format_sections_only(sections) return "" if sections.nil? || sections.empty? sorted_sections = sections.sort_by { |name, data| data[:priority] || data["priority"] || 999 } case @format when "markdown-xml" format_sections_markdown_xml(sorted_sections) when "markdown" format_sections_markdown(sorted_sections) when "yaml" format_sections_yaml(sorted_sections) when "json" format_sections_json(sorted_sections) else format_sections_markdown_xml(sorted_sections) end end |
#format_with_sections(bundle_data) ⇒ String
Formats bundle data with sections
15 16 17 18 19 20 21 22 |
# File 'lib/ace/bundle/molecules/section_formatter.rb', line 15 def format_with_sections(bundle_data) if bundle_data.has_sections? format_sections_output(bundle_data) else # Fallback to regular formatting format_legacy_output(bundle_data) end end |