Class: RR::WildcardMatchers::IsA

Inherits:
Object
  • Object
show all
Defined in:
lib/rr/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.



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

def initialize(klass)
  @klass = klass
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



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

def klass
  @klass
end

Instance Method Details

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



14
15
16
# File 'lib/rr/wildcard_matchers/is_a.rb', line 14

def ==(other)
  other.is_a?(self.class) && klass == other.klass
end

#inspectObject



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

def inspect
  "is_a(#{klass})"
end

#wildcard_match?(other) ⇒ Boolean

Returns:



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

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