Class: WildcardMatchers::WildcardMatcher
- Inherits:
-
Object
- Object
- WildcardMatchers::WildcardMatcher
- Defined in:
- lib/wildcard_matchers/wildcard_matcher.rb
Direct Known Subclasses
ArrayMatcher, HashMatcher, Helpers::AllOf, Helpers::AnyOf, Helpers::ForAll, Helpers::ForAny, Helpers::NilOr, Helpers::Responding, Matchers::BagOf, Matchers::HashIncludes, Matchers::IsUri, Matchers::WithUriTemplate, MethodMatcher
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#expectation ⇒ Object
readonly
Returns the value of attribute expectation.
-
#position ⇒ Object
Returns the value of attribute position.
Class Method Summary collapse
Instance Method Summary collapse
- #&(matcher) ⇒ Object
- #===(actual) ⇒ Object
-
#initialize(expectation = nil, position = ".", &block) ⇒ WildcardMatcher
constructor
A new instance of WildcardMatcher.
- #|(matcher) ⇒ Object
Constructor Details
#initialize(expectation = nil, position = ".", &block) ⇒ WildcardMatcher
Returns a new instance of WildcardMatcher.
6 7 8 9 |
# File 'lib/wildcard_matchers/wildcard_matcher.rb', line 6 def initialize(expectation = nil, position = ".", &block) @expectation = (block_given? ? block : expectation) @position = position end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'lib/wildcard_matchers/wildcard_matcher.rb', line 3 def errors @errors end |
#expectation ⇒ Object (readonly)
Returns the value of attribute expectation.
3 4 5 |
# File 'lib/wildcard_matchers/wildcard_matcher.rb', line 3 def expectation @expectation end |
#position ⇒ Object
Returns the value of attribute position.
4 5 6 |
# File 'lib/wildcard_matchers/wildcard_matcher.rb', line 4 def position @position end |
Class Method Details
.check_errors(actual, expectation = nil, position = ".", &block) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/wildcard_matchers/wildcard_matcher.rb', line 25 def self.check_errors(actual, expectation = nil, position = ".", &block) expectation = (block_given? ? block : expectation) matcher = self.new(expectation, position) matcher === actual matcher.errors end |
Instance Method Details
#&(matcher) ⇒ Object
11 12 13 |
# File 'lib/wildcard_matchers/wildcard_matcher.rb', line 11 def &(matcher) WildcardMatchers::Helpers::AllOf.new([self, matcher]) end |
#===(actual) ⇒ Object
19 20 21 22 23 |
# File 'lib/wildcard_matchers/wildcard_matcher.rb', line 19 def ===(actual) @errors = [] wildcard_match_with_catch_exception(actual) errors.empty? end |
#|(matcher) ⇒ Object
15 16 17 |
# File 'lib/wildcard_matchers/wildcard_matcher.rb', line 15 def |(matcher) WildcardMatchers::Helpers::AnyOf.new([self, matcher]) end |