Class: Muwu::RenderHtmlPartial::Contents
- Inherits:
-
Object
- Object
- Muwu::RenderHtmlPartial::Contents
show all
- Includes:
- Muwu
- Defined in:
- lib/muwu/render_html_partial/render_contents.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
#destination ⇒ Object
Returns the value of attribute destination.
9
10
11
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 9
def destination
@destination
end
|
#href_helper ⇒ Object
Returns the value of attribute href_helper.
9
10
11
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 9
def href_helper
@href_helper
end
|
#html_attr_id ⇒ Object
Returns the value of attribute html_attr_id.
9
10
11
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 9
def html_attr_id
@html_attr_id
end
|
#item_depth_max ⇒ Object
Returns the value of attribute item_depth_max.
9
10
11
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 9
def item_depth_max
@item_depth_max
end
|
#project ⇒ Object
Returns the value of attribute project.
9
10
11
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 9
def project
@project
end
|
#sections ⇒ Object
Returns the value of attribute sections.
9
10
11
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 9
def sections
@sections
end
|
#text_root_name ⇒ Object
Returns the value of attribute text_root_name.
9
10
11
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 9
def text_root_name
@text_root_name
end
|
#will_render_section_numbers ⇒ Object
Returns the value of attribute will_render_section_numbers.
9
10
11
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 9
def will_render_section_numbers
@will_render_section_numbers
end
|
Instance Method Details
#render ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 25
def render
@destination.margin_to_zero
@destination.padding_vertical(1) do
write_tag_div_open
render_contents_heading
render_contents_element(@sections)
write_tag_div_close
end
@destination.margin_to_zero
end
|
#render_contents_element(sections) ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 37
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_contents_heading ⇒ Object
49
50
51
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 49
def render_contents_heading
write_tag_h1_contents_heading
end
|
#render_ol(text_item) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 54
def render_ol(text_item)
write_tag_ol_open
@destination.margin_indent do
text_item.each do |section|
render_ol_li(section)
end
end
write_tag_ol_close
end
|
#render_ol_li(text_item) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 65
def render_ol_li(text_item)
if task_depth_is_within_range(text_item)
if text_item.is_parent_heading
write_tag_li_open
@destination.margin_indent do
render_ol_li_heading_and_subsections(text_item)
end
write_tag_li_close_outline
elsif text_item.is_not_parent_heading
write_tag_li_open
render_ol_li_heading(text_item)
write_tag_li_close_inline
end
end
end
|
#render_ol_li_heading(text_item) ⇒ Object
82
83
84
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 82
def render_ol_li_heading(text_item)
render_tag_a_section_heading(text_item)
end
|
#render_ol_li_heading_and_subsections(text_item) ⇒ Object
87
88
89
90
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 87
def render_ol_li_heading_and_subsections(text_item)
render_tag_a_section_heading(text_item, trailing_line_feed: true)
render_ol(text_item.sections)
end
|
#render_table(text_item) ⇒ Object
93
94
95
96
97
98
99
100
101
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 93
def render_table(text_item)
write_tag_table_open
@destination.margin_indent do
text_item.each do |section|
render_table_tr(section)
end
end
write_tag_table_close
end
|
#render_table_tr(section) ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 104
def render_table_tr(section)
if task_depth_is_within_range(section)
html_id = ['contents', @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_subsections(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
122
123
124
125
126
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 122
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_subsections(text_item) ⇒ Object
129
130
131
132
133
134
135
136
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 129
def render_table_tr_td_heading_and_subsections(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
139
140
141
142
143
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 139
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
146
147
148
149
150
151
152
153
154
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 146
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_item, attr_list: nil) ⇒ Object
157
158
159
160
161
162
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 157
def render_tag_a_section_number(text_item, attr_list: nil)
href = @href_helper.to_text_item(text_item)
write_tag_a_open(href, attr_list: attr_list)
write_text_section_number(text_item)
write_tag_a_close
end
|
#write_lf ⇒ Object
165
166
167
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 165
def write_lf
@destination.write_lf
end
|
#write_tag_a_close ⇒ Object
170
171
172
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 170
def write_tag_a_close
@destination.write_inline tag_a_close
end
|
#write_tag_a_open(href_id, attr_list: nil) ⇒ Object
175
176
177
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 175
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_close ⇒ Object
180
181
182
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 180
def write_tag_div_close
@destination.write_line tag_div_close
end
|
#write_tag_div_open ⇒ Object
185
186
187
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 185
def write_tag_div_open
@destination.write_line tag_div_open
end
|
#write_tag_h1_contents_heading ⇒ Object
190
191
192
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 190
def write_tag_h1_contents_heading
@destination.write_line tag_h1_contents_heading
end
|
#write_tag_li_close ⇒ Object
195
196
197
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 195
def write_tag_li_close
write_tag_li_close_outline
end
|
#write_tag_li_close_inline ⇒ Object
200
201
202
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 200
def write_tag_li_close_inline
@destination.write_inline_end tag_li_close
end
|
#write_tag_li_close_outline ⇒ Object
205
206
207
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 205
def write_tag_li_close_outline
@destination.write_line tag_li_close
end
|
#write_tag_li_open ⇒ Object
210
211
212
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 210
def write_tag_li_open
@destination.write_inline_indented tag_li_open
end
|
#write_tag_ol_close ⇒ Object
215
216
217
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 215
def write_tag_ol_close
@destination.write_line tag_ol_close
end
|
#write_tag_ol_open ⇒ Object
220
221
222
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 220
def write_tag_ol_open
@destination.write_line tag_ol_open
end
|
#write_tag_table_close ⇒ Object
225
226
227
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 225
def write_tag_table_close
@destination.write_line tag_table_close
end
|
#write_tag_table_open ⇒ Object
230
231
232
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 230
def write_tag_table_open
@destination.write_line tag_table_open
end
|
#write_tag_td_close ⇒ Object
235
236
237
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 235
def write_tag_td_close
write_tag_td_close_outline
end
|
#write_tag_td_close_inline ⇒ Object
240
241
242
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 240
def write_tag_td_close_inline
@destination.write_inline_end tag_td_close
end
|
#write_tag_td_close_outline ⇒ Object
245
246
247
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 245
def write_tag_td_close_outline
@destination.write_line tag_td_close
end
|
#write_tag_td_open(attr_list: nil) ⇒ Object
250
251
252
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 250
def write_tag_td_open(attr_list: nil)
@destination.write_inline_indented tag_td_open(attr_list: attr_list)
end
|
#write_tag_tr_close ⇒ Object
255
256
257
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 255
def write_tag_tr_close
@destination.write_line tag_tr_close
end
|
#write_tag_tr_open(html_id) ⇒ Object
260
261
262
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 260
def write_tag_tr_open(html_id)
@destination.write_line tag_tr_open(html_id)
end
|
#write_text_section_heading(textobject) ⇒ Object
265
266
267
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 265
def write_text_section_heading(textobject)
@destination.write_inline CGI::escape_html(textobject.heading)
end
|
#write_text_section_number(textobject) ⇒ Object
270
271
272
|
# File 'lib/muwu/render_html_partial/render_contents.rb', line 270
def write_text_section_number(textobject)
@destination.write_inline textobject.numbering.join('.')
end
|