Class: Pdfrb::Conformance::Rule
- Inherits:
-
Struct
- Object
- Struct
- Pdfrb::Conformance::Rule
- Defined in:
- lib/pdfrb/conformance/rule.rb
Overview
A single validation check. Each rule is self-contained: given a document, it returns zero or more Violations. Rules are registered into a RuleSet; adding a new check = defining a new Rule + registering it (no switch to edit — OCP).
Instance Attribute Summary collapse
-
#check ⇒ Object
Returns the value of attribute check.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#severity ⇒ Object
Returns the value of attribute severity.
-
#spec_clause ⇒ Object
Returns the value of attribute spec_clause.
Instance Method Summary collapse
Instance Attribute Details
#check ⇒ Object
Returns the value of attribute check
9 10 11 |
# File 'lib/pdfrb/conformance/rule.rb', line 9 def check @check end |
#description ⇒ Object
Returns the value of attribute description
9 10 11 |
# File 'lib/pdfrb/conformance/rule.rb', line 9 def description @description end |
#id ⇒ Object
Returns the value of attribute id
9 10 11 |
# File 'lib/pdfrb/conformance/rule.rb', line 9 def id @id end |
#severity ⇒ Object
Returns the value of attribute severity
9 10 11 |
# File 'lib/pdfrb/conformance/rule.rb', line 9 def severity @severity end |
#spec_clause ⇒ Object
Returns the value of attribute spec_clause
9 10 11 |
# File 'lib/pdfrb/conformance/rule.rb', line 9 def spec_clause @spec_clause end |
Instance Method Details
#evaluate(document) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/pdfrb/conformance/rule.rb', line 10 def evaluate(document) result = check.call(document) return [] unless result result.is_a?(::Array) ? result : [result] end |