Module: Nasty::Specification
- Included in:
- BlockSpecification
- Defined in:
- lib/nasty/block_specification.rb
Instance Method Summary collapse
- #and(other_predicate = nil, &block) ⇒ Object
- #not ⇒ Object
- #or(other_predicate = nil, &block) ⇒ Object
Instance Method Details
#and(other_predicate = nil, &block) ⇒ Object
8 9 10 11 |
# File 'lib/nasty/block_specification.rb', line 8 def and(other_predicate = nil, &block) matcher = create_predicate(other_predicate, &block) create_predicate { |item| self.matches?(item) && matcher.matches?(item) } end |
#not ⇒ Object
13 14 15 |
# File 'lib/nasty/block_specification.rb', line 13 def not create_predicate { |item| !self.matches?(item) } end |
#or(other_predicate = nil, &block) ⇒ Object
3 4 5 6 |
# File 'lib/nasty/block_specification.rb', line 3 def or(other_predicate = nil, &block) matcher = create_predicate(other_predicate, &block) create_predicate { |item| self.matches?(item) || matcher.matches?(item) } end |