class Muwu::RenderHtmlPartialBuilder::TextItemBuilder
Attributes
renderer[RW]
Public Class Methods
build() { |builder| ... }
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 14 def self.build builder = new yield(builder) builder.renderer end
new()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 21 def initialize @renderer = RenderHtmlPartial::TextItem.new end
Public Instance Methods
build_from_manifest_text_item(manifest_text_item)
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 26 def build_from_manifest_text_item(manifest_text_item) @manifest_text_item = manifest_text_item @project = manifest_text_item.project @href_helper = Helper::HtmlHrefHelper.new(manifest_text_item) phase_1_set_destination phase_1_set_heading phase_1_set_heading_origin phase_1_set_numbering phase_1_set_section_depth phase_1_set_section_number_as_attr phase_1_set_section_number_as_text phase_1_set_does_have_source_text phase_1_set_is_parent_heading phase_1_set_text_root_name phase_1_set_markdown_renderer phase_2_set_source_filename_absolute phase_2_set_source_filename_relative phase_3_set_sections phase_4_set_end_links phase_4_set_html_attr_id phase_4_set_will_render_section_number phase_4_set_subsections_are_distinct end
phase_1_set_destination()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 52 def phase_1_set_destination @renderer.destination = @manifest_text_item.destination end
phase_1_set_does_have_source_text()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 57 def phase_1_set_does_have_source_text if @manifest_text_item.source_file_does_exist @renderer.does_have_source_text = true elsif @manifest_text_item.source_file_does_not_exist @renderer.does_have_source_text = false end end
phase_1_set_heading()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 66 def phase_1_set_heading @renderer.heading = @manifest_text_item.heading end
phase_1_set_heading_origin()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 71 def phase_1_set_heading_origin @renderer.heading_origin = @manifest_text_item.heading_origin end
phase_1_set_is_parent_heading()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 76 def phase_1_set_is_parent_heading @renderer.is_parent_heading = @manifest_text_item.is_parent_heading end
phase_1_set_markdown_renderer()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 81 def phase_1_set_markdown_renderer @renderer.markup_renderer = Muwu::RenderMarkupToHtml.new(@project) end
phase_1_set_numbering()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 86 def phase_1_set_numbering @renderer.numbering = @manifest_text_item.numbering end
phase_1_set_options_commonmarker()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 91 def phase_1_set_options_commonmarker @renderer.options_commonmarker = [] if @project.options.render_punctuation_smart @renderer.options_commonmarker.append(:SMART) end end
phase_1_set_section_depth()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 99 def phase_1_set_section_depth @renderer.section_depth = @manifest_text_item.section_depth end
phase_1_set_section_number_as_attr()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 104 def phase_1_set_section_number_as_attr @renderer.section_number_as_attr = @manifest_text_item.numbering.join('_') end
phase_1_set_section_number_as_text()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 109 def phase_1_set_section_number_as_text @renderer.section_number_as_text = @manifest_text_item.numbering.join('.') end
phase_1_set_text_root_name()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 114 def phase_1_set_text_root_name @renderer.text_root_name = @manifest_text_item.text_root_name end
phase_2_set_source_filename_absolute()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 119 def phase_2_set_source_filename_absolute if @manifest_text_item.source_file_does_exist @renderer.source_filename_absolute = @manifest_text_item.source_filename_absolute end end
phase_2_set_source_filename_relative()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 126 def phase_2_set_source_filename_relative if @manifest_text_item.source_file_does_exist @renderer.source_filename_relative = @manifest_text_item.source_filename_relative end end
phase_3_set_sections()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 133 def phase_3_set_sections if @manifest_text_item.does_have_child_sections @renderer.sections = determine_sections end end
phase_4_set_end_links()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 140 def phase_4_set_end_links if text_item_should_have_end_links @renderer.end_links = determine_end_links end end
phase_4_set_html_attr_id()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 147 def phase_4_set_html_attr_id @renderer.html_attr_id = ['text', @renderer.text_root_name, @renderer.section_number_as_attr].join('_') end
phase_4_set_subsections_are_distinct()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 157 def phase_4_set_subsections_are_distinct @renderer.subsections_are_distinct = determine_whether_subsections_are_distinct end
phase_4_set_will_render_section_number()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 152 def phase_4_set_will_render_section_number @renderer.will_render_section_number = determine_whether_text_item_will_render_section_number end
Private Instance Methods
build_renderer_text_item(text_item)
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 166 def build_renderer_text_item(text_item) RenderHtmlPartialBuilder::TextItemBuilder.build do |b| b.build_from_manifest_text_item(text_item) end end
determine_end_links()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 173 def determine_end_links end_links = {} if @project.options.render_section_end_links @project.options.render_section_end_links.each do |link| end_links[link] = determine_end_links_href(link) end end end_links end
determine_end_links_href(link)
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 184 def determine_end_links_href(link) case link when 'contents' @href_helper.to_contents_heading(@manifest_text_item) when 'home' @href_helper.to_project_home when 'top' @href_helper.to_document_top end end
determine_sections()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 196 def determine_sections sections = [] @manifest_text_item.sections.each do |section| sections << build_renderer_text_item(section) end sections end
determine_whether_subsections_are_distinct()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 205 def determine_whether_subsections_are_distinct if @manifest_text_item.does_have_child_sections if @project.options.render_sections_distinctly_depth_max == nil return true elsif @renderer.section_depth < @project.options.render_sections_distinctly_depth_max return true elsif @renderer.section_depth >= @project.options.render_sections_distinctly_depth_max return false end end end
determine_whether_text_item_will_render_section_number()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 218 def determine_whether_text_item_will_render_section_number if @project.will_render_section_numbers && text_item_should_be_distinct true end end
text_item_distinct_parent_should_have_end_links()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 254 def text_item_distinct_parent_should_have_end_links if @renderer.does_have_source_text == true return true elsif @renderer.does_have_source_text == false return text_item_distinct_parent_without_source_should_have_end_links end end
text_item_distinct_parent_without_source_should_have_end_links()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 263 def text_item_distinct_parent_without_source_should_have_end_links if determine_whether_subsections_are_distinct == true return false elsif determine_whether_subsections_are_distinct == false return true end end
text_item_distinct_should_have_end_links()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 245 def text_item_distinct_should_have_end_links if @renderer.is_parent_heading return text_item_distinct_parent_should_have_end_links elsif @renderer.does_have_source_text return true end end
text_item_should_be_distinct()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 225 def text_item_should_be_distinct if @project.options.render_sections_distinctly_depth_max == nil return true elsif @renderer.section_depth <= @project.options.render_sections_distinctly_depth_max return true elsif @renderer.section_depth > @project.options.render_sections_distinctly_depth_max return false end end
text_item_should_have_end_links()
click to toggle source
# File lib/muwu/render_html_partial_builder/render_text_item_builder.rb, line 236 def text_item_should_have_end_links if text_item_should_be_distinct return text_item_distinct_should_have_end_links else return false end end