class Cassowary::Constraint

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.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(expression : Expression, operator : Operator, strength : Strength | Strength::Preset = Strength::REQUIRED) #

Creates a constraint stating that expression relates to zero by operator.


[View source]

Instance Method Detail

def expression : Expression #

[View source]
def inspect(io : IO) : Nil #
Description copied from class Reference

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>

[View source]
def operator : Operator #

[View source]
def strength(strength : Strength | Strength::Preset) : Constraint #

Returns a copy of this constraint with strength.


[View source]
def strength : Strength #

[View source]
def 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.


[View source]
def violated? : Bool #

Returns whether the variables' current values break this constraint, regardless of its strength.


[View source]