Class: Muwu::RenderConcat
- Inherits:
-
Object
- Object
- Muwu::RenderConcat
- Defined in:
- lib/muwu/render_concat/render_concat.rb
Instance Method Summary collapse
-
#initialize(project) ⇒ RenderConcat
constructor
A new instance of RenderConcat.
- #render ⇒ Object
- #render_topic(f, topic) ⇒ Object
- #render_topic_head(f, topic) ⇒ Object
- #render_topic_sections(f, topic) ⇒ Object
- #render_topic_source(f, topic) ⇒ Object
- #render_topic_spacer(f, topic) ⇒ Object
Constructor Details
#initialize(project) ⇒ RenderConcat
Returns a new instance of RenderConcat.
5 6 7 8 9 10 |
# File 'lib/muwu/render_concat/render_concat.rb', line 5 def initialize(project) @output_path = project.path_compiled @output_filename = project.html_basename + '.md' @project = project @manifest = project.manifest end |
Instance Method Details
#render ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/muwu/render_concat/render_concat.rb', line 16 def render destination = File.join(@output_path, @output_filename) puts "- Writing `#{@output_filename}`" File.open(destination, 'w') do |f| @manifest.text_blocks.each do |text| text.sections.each do |topic| render_topic(f, topic) end end end end |
#render_topic(f, topic) ⇒ Object
29 30 31 32 33 |
# File 'lib/muwu/render_concat/render_concat.rb', line 29 def render_topic(f, topic) render_topic_head(f, topic) render_topic_source(f, topic) render_topic_sections(f, topic) end |
#render_topic_head(f, topic) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/muwu/render_concat/render_concat.rb', line 36 def render_topic_head(f, topic) f.puts '# ' + topic.numbering.join('.') if heading_origin_is_basename_or_outline(topic) f.puts '# ' + topic.heading f.puts "\n" end end |
#render_topic_sections(f, topic) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/muwu/render_concat/render_concat.rb', line 45 def render_topic_sections(f, topic) if topic.does_have_child_sections topic.sections.each do |ti| render_topic(f, ti) end render_topic_spacer(f, topic) end end |
#render_topic_source(f, topic) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/muwu/render_concat/render_concat.rb', line 55 def render_topic_source(f, topic) if topic.source_file_does_exist f.puts topic.source.strip end render_topic_spacer(f, topic) end |
#render_topic_spacer(f, topic) ⇒ Object
63 64 65 |
# File 'lib/muwu/render_concat/render_concat.rb', line 63 def render_topic_spacer(f, topic) f.puts "\n\n\n\n" end |