Class: KeyVortex::Constraint::Minimum
- Defined in:
- lib/key_vortex/constraint/minimum.rb
Overview
Enforces that objects which respond to #>= are greater than the defined limit.
Instance Attribute Summary collapse
-
#limit ⇒ Integer
readonly
The minimum allowed value.
Instance Method Summary collapse
-
#accepts?(value) ⇒ Boolean
True if value >= limit.
-
#attribute ⇒ Symbol
:minimum.
-
#initialize(limit) ⇒ Minimum
constructor
A new instance of Minimum.
-
#within?(constraint) ⇒ Boolean
True if limit >= constraint.limit.
Methods inherited from Base
Constructor Details
#initialize(limit) ⇒ Minimum
Returns a new instance of Minimum.
14 15 16 17 |
# File 'lib/key_vortex/constraint/minimum.rb', line 14 def initialize(limit) super() @limit = limit end |
Instance Attribute Details
#limit ⇒ Integer (readonly)
Returns The minimum allowed value.
11 12 13 |
# File 'lib/key_vortex/constraint/minimum.rb', line 11 def limit @limit end |
Instance Method Details
#accepts?(value) ⇒ Boolean
Returns True if value >= limit.
32 33 34 |
# File 'lib/key_vortex/constraint/minimum.rb', line 32 def accepts?(value) value >= limit end |
#attribute ⇒ Symbol
Returns :minimum.
20 21 22 |
# File 'lib/key_vortex/constraint/minimum.rb', line 20 def attribute :minimum end |
#within?(constraint) ⇒ Boolean
Returns True if limit >= constraint.limit.
26 27 28 |
# File 'lib/key_vortex/constraint/minimum.rb', line 26 def within?(constraint) super && limit >= constraint.limit end |