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.



6
7
8
# File 'lib/rulp/constraint.rb', line 6

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

Instance Method Details

#constraint_opObject



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

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

#to_sObject



14
15
16
# File 'lib/rulp/constraint.rb', line 14

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

#variablesObject



10
11
12
# File 'lib/rulp/constraint.rb', line 10

def variables
  @expressions.variables
end