Class: Axe::API::Context
- Inherits:
-
Object
- Object
- Axe::API::Context
- Defined in:
- lib/axe/api/context.rb
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #excluding(*selectors) ⇒ Object
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #to_h ⇒ Object
- #to_hash ⇒ Object
- #to_json(options = nil) ⇒ Object (also: #to_s)
- #within(*selectors) ⇒ Object
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
6 7 8 9 |
# File 'lib/axe/api/context.rb', line 6 def initialize @inclusion = [] @exclusion = [] end |
Instance Method Details
#empty? ⇒ Boolean
34 35 36 |
# File 'lib/axe/api/context.rb', line 34 def empty? to_hash.empty? end |
#excluding(*selectors) ⇒ Object
15 16 17 |
# File 'lib/axe/api/context.rb', line 15 def excluding(*selectors) @exclusion.concat selectors.map { |s| Selector::normalize s } end |
#to_h ⇒ Object
19 20 21 |
# File 'lib/axe/api/context.rb', line 19 def to_h to_hash end |
#to_hash ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/axe/api/context.rb', line 22 def to_hash return { exclude: @exclusion } if @inclusion.empty? h = {} h["include"] = @inclusion unless @inclusion.empty? h["exclude"] = @exclusion unless @exclusion.empty? h end |
#to_json(options = nil) ⇒ Object Also known as: to_s
30 31 32 |
# File 'lib/axe/api/context.rb', line 30 def to_json( = nil) to_hash.to_json end |