Class: StringSatisfy::AndRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/string_satisfy/rule.rb

Overview

Boolean test for ‘and’ rule, like A & B

Instance Method Summary collapse

Methods inherited from Rule

#initialize, #normal_objects, #rule_objects

Constructor Details

This class inherits a constructor from StringSatisfy::Rule

Instance Method Details

#satisfied_with?(*objects) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
# File 'lib/string_satisfy/rule.rb', line 19

def satisfied_with?(*objects)
  objects = objects.map {|object| object.gsub(/\s+/, '') }.uniq
  return false unless normal_objects.all? {|normal_object| objects.include? normal_object }
  return false unless rule_objects.all? {|rule_object| rule_object.satisfied_with? *objects }
  true
end