Class: RR::Expectations::WildcardMatchers::IsA

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

Direct Known Subclasses

Numeric

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ IsA

Returns a new instance of IsA.



7
8
9
# File 'lib/rr/expectations/wildcard_matchers/is_a.rb', line 7

def initialize(klass)
  @klass = klass
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



5
6
7
# File 'lib/rr/expectations/wildcard_matchers/is_a.rb', line 5

def klass
  @klass
end

Instance Method Details

#==(other) ⇒ Object



15
16
17
18
# File 'lib/rr/expectations/wildcard_matchers/is_a.rb', line 15

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

#wildcard_match?(other) ⇒ Boolean

Returns:



11
12
13
# File 'lib/rr/expectations/wildcard_matchers/is_a.rb', line 11

def wildcard_match?(other)
  self == other || other.is_a?(klass)
end