Class: RR::WildcardMatchers::Satisfy

Inherits:
Object
  • Object
show all
Defined in:
lib/rr/wildcard_matchers/satisfy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expectation_proc) ⇒ Satisfy

Returns a new instance of Satisfy.



6
7
8
# File 'lib/rr/wildcard_matchers/satisfy.rb', line 6

def initialize(expectation_proc)
  @expectation_proc = expectation_proc
end

Instance Attribute Details

#expectation_procObject (readonly)

Returns the value of attribute expectation_proc.



4
5
6
# File 'lib/rr/wildcard_matchers/satisfy.rb', line 4

def expectation_proc
  @expectation_proc
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



19
20
21
22
# File 'lib/rr/wildcard_matchers/satisfy.rb', line 19

def ==(other)
  return false unless other.is_a?(self.class)
  self.expectation_proc == other.expectation_proc
end

#inspectObject



15
16
17
# File 'lib/rr/wildcard_matchers/satisfy.rb', line 15

def inspect
  "satisfy {block}"
end

#wildcard_match?(other) ⇒ Boolean

Returns:



10
11
12
13
# File 'lib/rr/wildcard_matchers/satisfy.rb', line 10

def wildcard_match?(other)
  return true if self == other
  !!expectation_proc.call(other)
end