Class: Matchi::Matcher::BeAnInstanceOf
- Defined in:
- lib/matchi/matcher/be_an_instance_of.rb
Overview
Type/class matcher.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(expected) ⇒ BeAnInstanceOf
constructor
Initialize the matcher with an object.
-
#inspect ⇒ String
A string containing a human-readable representation of the matcher.
-
#matches? ⇒ Boolean
Boolean comparison between the class of the actual value and the expected class.
-
#to_s ⇒ String
Returns a string representing the matcher instance.
Methods inherited from Base
Constructor Details
#initialize(expected) ⇒ BeAnInstanceOf
Initialize the matcher with an object.
15 16 17 18 |
# File 'lib/matchi/matcher/be_an_instance_of.rb', line 15 def initialize(expected) super() @expected = String(expected).to_sym end |
Instance Method Details
#inspect ⇒ String
A string containing a human-readable representation of the matcher.
21 22 23 |
# File 'lib/matchi/matcher/be_an_instance_of.rb', line 21 def inspect "#{self.class}(#{expected})" end |
#matches? ⇒ Boolean
Boolean comparison between the class of the actual value and the expected class.
41 42 43 |
# File 'lib/matchi/matcher/be_an_instance_of.rb', line 41 def matches?(*, **) self.class.const_get(expected).equal?(yield.class) end |
#to_s ⇒ String
Returns a string representing the matcher instance.
46 47 48 |
# File 'lib/matchi/matcher/be_an_instance_of.rb', line 46 def to_s "#{self.class.to_sym} #{expected}" end |