Class: Pdfrb::Conformance::Rule

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#checkObject

Returns the value of attribute check

Returns:

  • (Object)

    the current value of check



9
10
11
# File 'lib/pdfrb/conformance/rule.rb', line 9

def check
  @check
end

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



9
10
11
# File 'lib/pdfrb/conformance/rule.rb', line 9

def description
  @description
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



9
10
11
# File 'lib/pdfrb/conformance/rule.rb', line 9

def id
  @id
end

#severityObject

Returns the value of attribute severity

Returns:

  • (Object)

    the current value of severity



9
10
11
# File 'lib/pdfrb/conformance/rule.rb', line 9

def severity
  @severity
end

#spec_clauseObject

Returns the value of attribute spec_clause

Returns:

  • (Object)

    the current value of 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