Class: Matchi::Eql
- Inherits:
- BasicObject
- Defined in:
- lib/matchi/eql.rb
Overview
Equivalence matcher.
Instance Method Summary collapse
-
#initialize(expected) ⇒ Eql
constructor
Initialize the matcher with an object.
-
#matches? ⇒ Boolean
Boolean comparison between the actual value and the expected value.
-
#to_h ⇒ Hash
Returns a hash of one key-value pair with a key corresponding to the matcher and a value corresponding to its initialize parameters.
-
#to_s ⇒ String
Returns a string representing the matcher.
Constructor Details
#initialize(expected) ⇒ Eql
Initialize the matcher with an object.
10 11 12 |
# File 'lib/matchi/eql.rb', line 10 def initialize(expected) @expected = expected end |
Instance Method Details
#matches? ⇒ Boolean
Boolean comparison between the actual value and the expected value.
23 24 25 |
# File 'lib/matchi/eql.rb', line 23 def matches? @expected.eql?(yield) end |
#to_h ⇒ Hash
Returns a hash of one key-value pair with a key corresponding to the
matcher and a value corresponding to its initialize parameters.
46 47 48 |
# File 'lib/matchi/eql.rb', line 46 def to_h { Eql: [@expected] } end |
#to_s ⇒ String
Returns a string representing the matcher.
34 35 36 |
# File 'lib/matchi/eql.rb', line 34 def to_s "eql #{@expected.inspect}" end |