Class: Gecode::Constraints::SetEnum::Selection::SetAccessStub

Inherits:
ExpressionStub
  • Object
show all
Includes:
LeftHandSideMethods
Defined in:
lib/gecoder/interface/constraints/set_enum/selection.rb

Overview

Describes an expression stub started with a set var enum followed with an array access using a set variable.

Instance Method Summary collapse

Methods included from LeftHandSideMethods

#must, #must_not

Methods inherited from ExpressionStub

#initialize

Constructor Details

This class inherits a constructor from Gecode::Constraints::ExpressionStub

Instance Method Details

#intersection(options = {}) ⇒ Object

Starts a intersection selection constraint on the selected sets. The option :with may optionally be specified, in which case the value should be an enumeration of the elements in the universe.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/gecoder/interface/constraints/set_enum/selection.rb', line 48

def intersection(options = {})
  unless options.empty? 
    unless options.size == 1 and options.has_key?(:with)
      raise ArgumentError, "Expected option key :with, got #{options.keys}."
    else
      universe = options[:with]
      unless universe.kind_of?(Enumerable) and 
          universe.all?{ |element| element.kind_of? Fixnum }
        raise TypeError, "Expected the universe to be specified as " + 
          "an enumeration of fixnum, got #{universe.class}."
      end
      @params.update(:universe => universe)
    end
  end
  
  IntersectionExpressionStub.new(@model, @params)
end

#unionObject

Starts a union selection constraint on the selected sets.



41
42
43
# File 'lib/gecoder/interface/constraints/set_enum/selection.rb', line 41

def union
  UnionExpressionStub.new(@model, @params)
end