Class: Cuporter::Filter
- Inherits:
-
Object
- Object
- Cuporter::Filter
- Defined in:
- lib/cuporter/filter.rb
Instance Attribute Summary collapse
-
#all ⇒ Object
readonly
Returns the value of attribute all.
-
#any ⇒ Object
readonly
Returns the value of attribute any.
-
#none ⇒ Object
readonly
Returns the value of attribute none.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(args = {}) ⇒ Filter
constructor
A new instance of Filter.
- #pass?(other_tags) ⇒ Boolean
Constructor Details
#initialize(args = {}) ⇒ Filter
Returns a new instance of Filter.
7 8 9 10 11 |
# File 'lib/cuporter/filter.rb', line 7 def initialize(args = {}) @all = to_tag_array(args[:all]) # logical AND @any = to_tag_array(args[:any]) # logical OR @none = to_tag_array(args[:none])# logical NOT end |
Instance Attribute Details
#all ⇒ Object (readonly)
Returns the value of attribute all.
5 6 7 |
# File 'lib/cuporter/filter.rb', line 5 def all @all end |
#any ⇒ Object (readonly)
Returns the value of attribute any.
5 6 7 |
# File 'lib/cuporter/filter.rb', line 5 def any @any end |
#none ⇒ Object (readonly)
Returns the value of attribute none.
5 6 7 |
# File 'lib/cuporter/filter.rb', line 5 def none @none end |
Instance Method Details
#empty? ⇒ Boolean
33 34 35 |
# File 'lib/cuporter/filter.rb', line 33 def empty? all.empty? && any.empty? && none.empty? end |
#pass?(other_tags) ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cuporter/filter.rb', line 13 def pass?() pass = true # Logical AND: are all of the tags in :all in the tests' tags? unless all.empty? pass = false unless ( & all).size == all.size end # Logical OR: are any of the tests' tags in :any? unless any.empty? pass = false if ( & any).empty? end unless none.empty? pass = false if !( & none).empty? end pass end |