Class: Contracts::Builtin::Eq
- Inherits:
-
CallableClass
- Object
- CallableClass
- Contracts::Builtin::Eq
- Defined in:
- lib/contracts-ruby2/lib/contracts/builtin_contracts.rb,
lib/contracts-ruby3/lib/contracts/builtin_contracts.rb
Overview
Takes a value v
. If the argument is .equal
to v
, the contract passes, otherwise the contract fails. Example: Eq[Class]
Instance Method Summary collapse
-
#initialize(value) ⇒ Eq
constructor
A new instance of Eq.
- #to_s ⇒ Object
- #valid?(val) ⇒ Boolean
Methods inherited from CallableClass
Constructor Details
#initialize(value) ⇒ Eq
Returns a new instance of Eq.
237 238 239 |
# File 'lib/contracts-ruby2/lib/contracts/builtin_contracts.rb', line 237 def initialize(value) @value = value end |
Instance Method Details
#to_s ⇒ Object
245 246 247 |
# File 'lib/contracts-ruby2/lib/contracts/builtin_contracts.rb', line 245 def to_s "to be equal to #{@value.inspect}" end |
#valid?(val) ⇒ Boolean
241 242 243 |
# File 'lib/contracts-ruby2/lib/contracts/builtin_contracts.rb', line 241 def valid?(val) @value.equal?(val) end |