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