Class: Uniword::Quality::TableHeaderRule
- Inherits:
-
QualityRule
- Object
- QualityRule
- Uniword::Quality::TableHeaderRule
- Defined in:
- lib/uniword/quality/rules/table_header_rule.rb
Overview
Checks that tables have proper header rows.
Responsibility: Validate table structure and headers. Single Responsibility - only checks table headers.
Validates:
-
Tables have at least one header row
-
Header rows are properly marked
-
Tables are accessible
Instance Attribute Summary
Attributes inherited from QualityRule
Instance Method Summary collapse
-
#check(document) ⇒ Array<QualityViolation>
Check document for table header violations.
-
#initialize(config = {}) ⇒ TableHeaderRule
constructor
A new instance of TableHeaderRule.
Methods inherited from QualityRule
Constructor Details
#initialize(config = {}) ⇒ TableHeaderRule
Returns a new instance of TableHeaderRule.
20 21 22 23 |
# File 'lib/uniword/quality/rules/table_header_rule.rb', line 20 def initialize(config = {}) super @require_headers = @config.fetch(:require_headers, true) end |
Instance Method Details
#check(document) ⇒ Array<QualityViolation>
Check document for table header violations
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/uniword/quality/rules/table_header_rule.rb', line 29 def check(document) violations = [] return violations unless @require_headers document.tables.each_with_index do |table, index| next if has_header_row?(table) violations << create_violation( severity: :warning, message: "Table #{index + 1} does not have a header row. " \ "Headers improve accessibility and readability.", location: "Table #{index + 1}", element: table, ) end violations end |