Class: Constraint

Inherits:
Object show all
Defined in:
lib/rulp/constraint.rb

Overview

An LP Expression constraint. A mathematical expression of which the result must be constrained in some way.

Instance Method Summary collapse

Constructor Details

#initialize(*constraint_expression) ⇒ Constraint

Returns a new instance of Constraint.



8
9
10
# File 'lib/rulp/constraint.rb', line 8

def initialize(*constraint_expression)
  @expressions , @constraint_op, @value = constraint_expression
end

Instance Method Details

#constraint_opObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rulp/constraint.rb', line 20

def constraint_op
  case "#{@constraint_op}"
  when "=="
    "="
  when "<"
    "<="
  when ">"
    ">="
  else
    @constraint_op
  end
end

#to_sObject



16
17
18
# File 'lib/rulp/constraint.rb', line 16

def to_s
  return "#{@expressions} #{constraint_op} #{@value}"
end

#variablesObject



12
13
14
# File 'lib/rulp/constraint.rb', line 12

def variables
  @expressions.variables
end