Class: Uniword::Lint::BuiltinRules::RequireBody

Inherits:
Rule
  • Object
show all
Defined in:
lib/uniword/lint/builtin_rules/require_body.rb

Overview

Rule: documents must have a non-empty body.

Constant Summary

Constants inherited from Rule

Rule::TYPES

Instance Attribute Summary

Attributes inherited from Rule

#name, #options, #severity

Instance Method Summary collapse

Methods inherited from Rule

#finding, #initialize, register, type, types

Constructor Details

This class inherits a constructor from Uniword::Lint::Rule

Instance Method Details

#check(document) {|finding( message: "Document body is empty", path: "word/document.xml", )| ... } ⇒ Object

Yields:

  • (finding( message: "Document body is empty", path: "word/document.xml", ))


10
11
12
13
14
15
16
17
18
19
# File 'lib/uniword/lint/builtin_rules/require_body.rb', line 10

def check(document)
  body = document.body
  paragraphs = body&.paragraphs || []
  return if paragraphs.any?

  yield finding(
    message: "Document body is empty",
    path: "word/document.xml",
  )
end