Class: Muwu::RenderHtmlPartial::Subcontents

Inherits:
Object
  • Object
show all
Includes:
Muwu
Defined in:
lib/muwu/render_html_partial/render_subcontents.rb

Constant Summary

Constants included from Muwu

GEM_HOME_LIB, GEM_HOME_LIB_MUWU, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Muwu

debug, read

Instance Attribute Details

#destinationObject

Returns the value of attribute destination.



9
10
11
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 9

def destination
  @destination
end

#href_helperObject

Returns the value of attribute href_helper.



9
10
11
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 9

def href_helper
  @href_helper
end

#html_attr_idObject

Returns the value of attribute html_attr_id.



9
10
11
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 9

def html_attr_id
  @html_attr_id
end

#item_depth_maxObject

Returns the value of attribute item_depth_max.



9
10
11
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 9

def item_depth_max
  @item_depth_max
end

#projectObject

Returns the value of attribute project.



9
10
11
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 9

def project
  @project
end

#sectionsObject

Returns the value of attribute sections.



9
10
11
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 9

def sections
  @sections
end

#text_root_blockObject

Returns the value of attribute text_root_block.



9
10
11
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 9

def text_root_block
  @text_root_block
end

#text_root_blocksObject

Returns the value of attribute text_root_blocks.



9
10
11
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 9

def text_root_blocks
  @text_root_blocks
end

#text_root_nameObject

Returns the value of attribute text_root_name.



9
10
11
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 9

def text_root_name
  @text_root_name
end

#will_render_section_numbersObject

Returns the value of attribute will_render_section_numbers.



9
10
11
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 9

def will_render_section_numbers
  @will_render_section_numbers
end

Instance Method Details

#renderObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 27

def render
  @destination.margin_to_zero
  @destination.padding_vertical(1) do
    write_tag_div_open
    render_project_title
    @text_root_blocks.each do |text_root_block|
      render_contents_element(text_root_block.sections)
    end
    write_tag_div_close
  end
  @destination.margin_to_zero
end

#render_contents_element(sections) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 41

def render_contents_element(sections)
  @destination.margin_indent do
    case @will_render_section_numbers
    when false
      render_ol(sections)
    when true
      render_table(sections)
    end
  end
end

#render_ol(sections) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 53

def render_ol(sections)
  write_tag_ol_open
  @destination.margin_indent do 
    sections.each do |section|
      render_ol_li(section)
    end
  end
  write_tag_ol_close
end

#render_ol_li(section) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 64

def render_ol_li(section)
  if task_depth_is_within_range(section)
    case section
    when ManifestTask::TextReadfile
      write_tag_li_open
      render_ol_li_heading(section)
      write_tag_li_close_inline
    when ManifestTask::TextGroup
      write_tag_li_open
      @destination.margin_indent do 
        render_ol_li_heading_and_text_item(section)
      end
      write_tag_li_close_outline
    end
  end
end

#render_ol_li_heading(text_item) ⇒ Object



82
83
84
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 82

def render_ol_li_heading(text_item)
  render_tag_a_section_heading(text_item)
end

#render_ol_li_heading_and_text_item(text_item) ⇒ Object



87
88
89
90
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 87

def render_ol_li_heading_and_text_item(text_item)
  render_tag_a_section_heading(text_item, trailing_line_feed: true)
  render_ol(text_item.sections)
end

#render_project_titleObject



93
94
95
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 93

def render_project_title
  write_tag_h1_title
end

#render_table(sections) ⇒ Object



98
99
100
101
102
103
104
105
106
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 98

def render_table(sections)
  write_tag_table_open
  @destination.margin_indent do 
    sections.each do |section|
      render_table_tr(section)
    end
  end
  write_tag_table_close
end

#render_table_tr(section) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 109

def render_table_tr(section)
  if task_depth_is_within_range(section)
    html_id = ['subcontents', @text_root_name, section.numbering.join('_')].join('_')
    write_tag_tr_open(html_id)
    @destination.margin_indent do 
      if section.is_parent_heading
        render_table_tr_td_number(section)
        render_table_tr_td_heading_and_text_item(section)
      elsif section.is_not_parent_heading
        render_table_tr_td_number(section)
        render_table_tr_td_heading(section)
      end
    end
    write_tag_tr_close
  end
end

#render_table_tr_td_heading(text_item) ⇒ Object



127
128
129
130
131
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 127

def render_table_tr_td_heading(text_item)
  write_tag_td_open(attr_list: "class='heading'")
  render_tag_a_section_heading(text_item)
  write_tag_td_close_inline
end

#render_table_tr_td_heading_and_text_item(text_item) ⇒ Object



134
135
136
137
138
139
140
141
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 134

def render_table_tr_td_heading_and_text_item(text_item)
  write_tag_td_open(attr_list: "class='heading'")
  render_tag_a_section_heading(text_item, trailing_line_feed: true)
  @destination.margin_indent do
    render_table(text_item.sections)
  end
  write_tag_td_close_outline
end

#render_table_tr_td_number(text_item) ⇒ Object



144
145
146
147
148
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 144

def render_table_tr_td_number(text_item)
  write_tag_td_open(attr_list: "class='number'")
  render_tag_a_section_number(text_item, attr_list: "tabindex='-1'")
  write_tag_td_close_inline
end

#render_tag_a_section_heading(text_item, trailing_line_feed: false) ⇒ Object



151
152
153
154
155
156
157
158
159
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 151

def render_tag_a_section_heading(text_item, trailing_line_feed: false)
  href = @href_helper.to_text_item(text_item)
  write_tag_a_open(href)
  write_text_section_heading(text_item)
  write_tag_a_close
  if trailing_line_feed
    write_lf
  end
end

#render_tag_a_section_number(text_object, attr_list: nil) ⇒ Object



162
163
164
165
166
167
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 162

def render_tag_a_section_number(text_object, attr_list: nil)
  href = @href_helper.to_text_item(text_object)
  write_tag_a_open(href, attr_list: attr_list)
  write_text_section_number(text_object)
  write_tag_a_close
end

#write_lfObject



170
171
172
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 170

def write_lf
  @destination.write_lf
end

#write_tag_a_closeObject



175
176
177
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 175

def write_tag_a_close
  @destination.write_inline tag_a_close
end

#write_tag_a_open(href_id, attr_list: nil) ⇒ Object



180
181
182
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 180

def write_tag_a_open(href_id, attr_list: nil)
  @destination.write_inline tag_a_open(href_id, attr_list: attr_list)
end

#write_tag_div_closeObject



185
186
187
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 185

def write_tag_div_close
  @destination.write_line tag_div_close
end

#write_tag_div_openObject



190
191
192
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 190

def write_tag_div_open
  @destination.write_line tag_div_open
end

#write_tag_h1_titleObject



195
196
197
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 195

def write_tag_h1_title
  @destination.write_line tag_h1_title
end

#write_tag_li_closeObject



200
201
202
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 200

def write_tag_li_close
  write_tag_li_close_outline
end

#write_tag_li_close_inlineObject



205
206
207
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 205

def write_tag_li_close_inline
  @destination.write_inline_end tag_li_close
end

#write_tag_li_close_outlineObject



210
211
212
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 210

def write_tag_li_close_outline
  @destination.write_line tag_li_close
end

#write_tag_li_openObject



215
216
217
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 215

def write_tag_li_open
  @destination.write_inline_indented tag_li_open
end

#write_tag_ol_closeObject



220
221
222
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 220

def write_tag_ol_close
  @destination.write_line tag_ol_close
end

#write_tag_ol_openObject



225
226
227
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 225

def write_tag_ol_open
  @destination.write_line tag_ol_open
end

#write_tag_table_closeObject



230
231
232
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 230

def write_tag_table_close
  @destination.write_line tag_table_close
end

#write_tag_table_openObject



235
236
237
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 235

def write_tag_table_open
  @destination.write_line tag_table_open
end

#write_tag_td_closeObject



240
241
242
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 240

def write_tag_td_close
  write_tag_td_close_outline
end

#write_tag_td_close_inlineObject



245
246
247
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 245

def write_tag_td_close_inline
  @destination.write_inline_end tag_td_close
end

#write_tag_td_close_outlineObject



250
251
252
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 250

def write_tag_td_close_outline
  @destination.write_line tag_td_close
end

#write_tag_td_open(attr_list: nil) ⇒ Object



255
256
257
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 255

def write_tag_td_open(attr_list: nil)
  @destination.write_inline_indented tag_td_open(attr_list: attr_list)
end

#write_tag_tr_closeObject



260
261
262
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 260

def write_tag_tr_close
  @destination.write_line tag_tr_close
end

#write_tag_tr_open(html_id) ⇒ Object



265
266
267
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 265

def write_tag_tr_open(html_id)
  @destination.write_line tag_tr_open(html_id)
end

#write_text_section_heading(text_item) ⇒ Object



270
271
272
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 270

def write_text_section_heading(text_item)
  @destination.write_inline text_item.heading
end

#write_text_section_number(text_item) ⇒ Object



275
276
277
# File 'lib/muwu/render_html_partial/render_subcontents.rb', line 275

def write_text_section_number(text_item)
  @destination.write_inline text_item.numbering.join('.')
end