Class: PageHTML
- Defined in:
- lib/html_compilation/classes/builders/page_html.rb
Instance Attribute Summary collapse
-
#rows ⇒ Object
Returns the value of attribute rows.
Attributes inherited from HTML
Instance Method Summary collapse
- #build ⇒ Object
- #gen_image_section ⇒ Object
- #gen_sup_rules_area ⇒ Object
- #gen_url_section ⇒ Object
-
#initialize(object) ⇒ PageHTML
constructor
A new instance of PageHTML.
- #warning_header_gen ⇒ Object
Methods inherited from HTML
Methods included from YAMLInteraction
Constructor Details
#initialize(object) ⇒ PageHTML
Returns a new instance of PageHTML.
5 6 7 8 9 |
# File 'lib/html_compilation/classes/builders/page_html.rb', line 5 def initialize(object) self.send("data_location=", File.("../../../data/html_data/page_data.yaml", __FILE__)) self.send("rows=", object.rows) super(object) end |
Instance Attribute Details
#rows ⇒ Object
Returns the value of attribute rows.
4 5 6 |
# File 'lib/html_compilation/classes/builders/page_html.rb', line 4 def rows @rows end |
Instance Method Details
#build ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/html_compilation/classes/builders/page_html.rb', line 11 def build #populate warning headers row_headers = warning_header_gen #populate list of warning from the row row_content = rows.map do |row| rhtml = RowHTML.new(row) rhtml.build end.join #populate the warning list area as a whole. warn_list = read_yaml(data_location, "WARNING_LIST_AREA") warn_list.gsub!('header_sample', row_headers) warn_list.gsub!('rows_sample', row_content) #generate the page info section page_info = read_yaml(data_location, "PAGE_INFO") url = gen_url_section image = gen_image_section sup_rule_area = gen_sup_rules_area page_info.gsub!('sample', url + image + sup_rule_area) #generate the content section which combines page_info and warn_list content = read_yaml(data_location, "CONTENT") content.gsub!('sample', page_info + warn_list) #generate the collapsible_button_section cb = read_yaml(data_location, "COLLAPSIBLE_BUTTON") cb.gsub!("Sample Page Name", object.page) cb.gsub!("sample total number of errors", object.rows.length.to_s) cb.gsub!("sample page score", object.score.to_s) #generate the whole page content section cls = read_yaml(data_location, "COLLAPSIBLE_LIST_SECTION") cls.gsub!("sample", cb + content) cls end |
#gen_image_section ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/html_compilation/classes/builders/page_html.rb', line 59 def gen_image_section if object.image != nil html = read_yaml(data_location, "PAGE_IMAGE") output = html.gsub("sample", htmlify(object.page)) else output = "" end output end |
#gen_sup_rules_area ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/html_compilation/classes/builders/page_html.rb', line 79 def gen_sup_rules_area if object.page_suppressed_rules != nil table_value = read_yaml(data_location, "PAGE_SUPPRESSED_RULES_TABLE_VALUES") psr = object.page_suppressed_rules.map do |rule| table_value.gsub("sample","<strong>Guideline: </strong>" + htmlify(rule.guideline) + "<strong> Content: </strong>" + htmlify(rule.content)) end output = read_yaml(data_location, "PAGE_SUPPRESSED_RULES_AREA").gsub("sample", psr.join.to_s) else output = "" end output end |
#gen_url_section ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/html_compilation/classes/builders/page_html.rb', line 69 def gen_url_section if object.url != nil html = read_yaml(data_location, "PAGE_URL") output = html.gsub("sample", htmlify(object.url)) else output = "" end output end |
#warning_header_gen ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/html_compilation/classes/builders/page_html.rb', line 50 def warning_header_gen headers = read_yaml(data_location, "WARNING_LIST_HEADERS") output = rows[0].values.map do |key| headers.gsub("sample", key) end output.push(headers.gsub("sample", "instances")) output.join.to_s end |