Class: Uniword::Lint::BuiltinRules::RequiredStyle
- Defined in:
- lib/uniword/lint/builtin_rules/required_style.rb
Overview
Rule: required style presence. Triggers when the named style is missing from the document.
Constant Summary
Constants inherited from Rule
Instance Attribute Summary
Attributes inherited from Rule
Instance Method Summary collapse
- #check(document) ⇒ Object
-
#initialize(style_id:, **rest) ⇒ RequiredStyle
constructor
A new instance of RequiredStyle.
Methods inherited from Rule
#finding, register, type, types
Constructor Details
#initialize(style_id:, **rest) ⇒ RequiredStyle
Returns a new instance of RequiredStyle.
12 13 14 15 |
# File 'lib/uniword/lint/builtin_rules/required_style.rb', line 12 def initialize(style_id:, **rest) super(**rest) @required = Array(style_id) end |
Instance Method Details
#check(document) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/uniword/lint/builtin_rules/required_style.rb', line 17 def check(document) present = document.styles_configuration&.styles&.map(&:styleId) || [] @required.each do |id| next if present.include?(id) yield finding( message: "Required style '#{id}' is missing", path: "styles.xml", ) end end |