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

- (IsA) initialize(klass)



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

def initialize(klass)
  @klass = klass
end

Instance Attribute Details

- (Object) klass (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

- (Object) ==(other) Also known as: eql?



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

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

- (Object) inspect



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

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

- (Boolean) wildcard_match?(other)



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

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