Class: Ree::Contracts::ArgContracts::Eq
Instance Attribute Summary collapse
-
#contract ⇒ Object
readonly
Returns the value of attribute contract.
Instance Method Summary collapse
-
#initialize(contract) ⇒ Eq
constructor
A new instance of Eq.
- #message(value, name, lvl = 1) ⇒ Object
- #to_s ⇒ Object
- #valid?(value) ⇒ Boolean
Methods included from Squarable
Methods included from Truncatable
Constructor Details
#initialize(contract) ⇒ Eq
Returns a new instance of Eq.
11 12 13 |
# File 'lib/ree/contracts/arg_contracts/eq.rb', line 11 def initialize(contract) @contract = contract end |
Instance Attribute Details
#contract ⇒ Object (readonly)
Returns the value of attribute contract.
9 10 11 |
# File 'lib/ree/contracts/arg_contracts/eq.rb', line 9 def contract @contract end |
Instance Method Details
#message(value, name, lvl = 1) ⇒ Object
23 24 25 |
# File 'lib/ree/contracts/arg_contracts/eq.rb', line 23 def (value, name, lvl = 1) "expected #{truncate(self.to_s, 30)}, got #{truncate(value.inspect)}" end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/ree/contracts/arg_contracts/eq.rb', line 19 def to_s "Eq[#{contract.inspect}]" end |
#valid?(value) ⇒ Boolean
15 16 17 |
# File 'lib/ree/contracts/arg_contracts/eq.rb', line 15 def valid?(value) value.equal?(contract) end |