module Cassowary::Operand

Overview

Provides the arithmetic operators that build an Expression and the comparison operators that build a Constraint.

Included by Variable, Term and Expression. Number accepts operands on its right side too.

x = Variable.new("x")
y = Variable.new("y")
2 * x + y / 2 - 10 # => Expression
x + 10 <= y        # => Constraint

NOTE #== builds a constraint, so it does not test equality, and #!= does not compile. Use same? to compare variables.

Direct including types

Defined in:

cassowary/operand.cr

Instance Method Summary

Instance Method Detail

def !=(other : Operand | Number) : NoReturn #

Fails to compile: an inequation is not a linear constraint, and #!= would otherwise negate a Constraint into false. Use same? to compare variables.


[View source]
def *(other : Number) : Expression #

Returns this operand multiplied by other.


[View source]
def +(other : Operand) : Expression #

Returns the sum of this operand and other.


[View source]
def +(other : Number) : Expression #

Returns the sum of this operand and other.


[View source]
def -(other : Operand) : Expression #

Returns the difference of this operand and other.


[View source]
def -(other : Number) : Expression #

Returns the difference of this operand and other.


[View source]
def - : Expression #

Returns the negation of this operand.


[View source]
def /(other : Number) : Expression #

Returns this operand divided by other.


[View source]
def <=(other : Operand | Number) : Constraint #

Returns a required constraint that this operand is at most other.


[View source]
def ==(other : Operand | Number) : Constraint #

Returns a required constraint that this operand equals other.


[View source]
def >=(other : Operand | Number) : Constraint #

Returns a required constraint that this operand is at least other.


[View source]
abstract def to_expression : Expression #

Returns this operand as an expression.


[View source]