Class: KeyVortex::Constraint::Base
- Inherits:
-
Object
- Object
- KeyVortex::Constraint::Base
- Defined in:
- lib/key_vortex/constraint/base.rb
Overview
Base class all other constraints inherit from. Does not define all of the properties necessary for a constraint, and so is inappropriate to be used directly.
Instance Method Summary collapse
-
#applies_to?(constraint) ⇒ Boolean
Comparing constraints is only valid when compared to other instances of the same constraint.
-
#to_s ⇒ String
A text description of the constraint.
-
#within?(constraint) ⇒ Boolean
The individual constraint is responsible for making the ultimate determination of if it is within another constraint.
Instance Method Details
#applies_to?(constraint) ⇒ Boolean
Comparing constraints is only valid when compared to other instances of the same constraint. This helps other parts of the system determine if this is true.
14 15 16 |
# File 'lib/key_vortex/constraint/base.rb', line 14 def applies_to?(constraint) attribute == constraint.attribute end |
#to_s ⇒ String
A text description of the constraint. Assumes subclasses define the methods attribute and limit.
29 30 31 |
# File 'lib/key_vortex/constraint/base.rb', line 29 def to_s "#{attribute}: #{limit}" end |
#within?(constraint) ⇒ Boolean
The individual constraint is responsible for making the ultimate determination of if it is within another constraint. What’s common to all of them, though, is that they must be the same class.
22 23 24 |
# File 'lib/key_vortex/constraint/base.rb', line 22 def within?(constraint) constraint.instance_of?(self.class) end |