Class: Axe::API::Rules
- Inherits:
-
Object
- Object
- Axe::API::Rules
- Defined in:
- lib/axe/api/rules.rb
Instance Method Summary collapse
- #according_to(*tags) ⇒ Object
- #checking(*rules) ⇒ Object
- #checking_only(*rules) ⇒ Object
-
#initialize ⇒ Rules
constructor
A new instance of Rules.
- #skipping(*rules) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize ⇒ Rules
Returns a new instance of Rules.
4 5 6 7 8 9 |
# File 'lib/axe/api/rules.rb', line 4 def initialize @tags = [] @included = [] @excluded = [] @exclusive = [] end |
Instance Method Details
#according_to(*tags) ⇒ Object
11 12 13 |
# File 'lib/axe/api/rules.rb', line 11 def according_to(*) @tags.concat .flatten end |
#checking(*rules) ⇒ Object
15 16 17 |
# File 'lib/axe/api/rules.rb', line 15 def checking(*rules) @included.concat rules.flatten end |
#checking_only(*rules) ⇒ Object
19 20 21 |
# File 'lib/axe/api/rules.rb', line 19 def checking_only(*rules) @exclusive.concat rules.flatten end |
#skipping(*rules) ⇒ Object
23 24 25 |
# File 'lib/axe/api/rules.rb', line 23 def skipping(*rules) @excluded.concat rules.flatten end |
#to_hash ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/axe/api/rules.rb', line 27 def to_hash {}.tap do || # TODO warn that tags + exclusive-rules are incompatible .merge! runOnly: { type: :tag, values: @tags } unless @tags.empty? .merge! runOnly: { type: :rule, values: @exclusive } unless @exclusive.empty? .merge! rules: Hash[@included.product([enabled: true]) + @excluded.product([enabled: false])] unless @included.empty? && @excluded.empty? end end |