Describes an integer variable.
An integer variable can take the value of any integer in its domain, which is specified upon constructing the variable and further constrained by placing constraints on the variable. An integer variable is said to be assigned once the domain only contains a single element, at which point value can be used to retrieve the value.
Integer variables are integer operands and hence respond to everything that Gecode::Int::IntOperand responds to. Any constraint found in Gecode::Int::IntConstraintReceiver can thereby be placed on integer variables.
Returns an enumeration corresponding to the domain.
# File lib/gecoder/interface/variables.rb, line 120 def domain if range? min..max else (min..max).select do |i| include? i end end end
Returns the receiver.
# File lib/gecoder/interface/variables.rb, line 115 def to_int_var self end
Gets the value of the assigned integer variable (a Fixnum). The variable must be assigned, if it isn’t then a RuntimeError is raised.
# File lib/gecoder/interface/variables.rb, line 109 def value raise 'No value is assigned.' unless assigned? send_bound(:val) end