class
Cassowary::Constraint
- Cassowary::Constraint
- Reference
- Object
Overview
A linear relation between an expression and zero, with a strength.
Build constraints with the comparison operators of Operand:
(x + 10 <= y).strength(:medium)
A constraint is immutable; the solver identifies it by object identity.
Defined in:
cassowary/constraint.crConstructors
-
.new(expression : Expression, operator : Operator, strength : Strength | Strength::Preset = Strength::REQUIRED)
Creates a constraint stating that expression relates to zero by operator.
Instance Method Summary
- #expression : Expression
-
#inspect(io : IO) : Nil
Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.
- #operator : Operator
-
#strength(strength : Strength | Strength::Preset) : Constraint
Returns a copy of this constraint with strength.
- #strength : Strength
-
#to_s(io : IO) : Nil
Writes the constraint in readable form, such as
x + 10 <= y | strong: positive terms on the left, negative ones on the right, and the strength unless required. -
#violated? : Bool
Returns whether the variables' current values break this constraint, regardless of its strength.
Constructor Detail
Creates a constraint stating that expression relates to zero by operator.
Instance Method Detail
Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>
Returns a copy of this constraint with strength.
Writes the constraint in readable form, such as x + 10 <= y | strong: positive
terms on the left, negative ones on the right, and the strength unless required.
Returns whether the variables' current values break this constraint, regardless of its strength.