Gecoder C0 Coverage Information - RCov

lib/gecoder/interface/constraints/set_elements_constraints.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/gecoder/interface/constraints/set_elements_constraints.rb 97 37
100.00%
100.00%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 # A module containing constraints that have set.elements as left hand
2 # side.
3 module Gecode::SetElements #:nodoc:
4   # A SetElementsOperand is an uncommon operand that results from calling 
5   # SetOperand#elements. It facilitates placing the constraints defined
6   # in SetElementsConstraintReceiver
7   #
8   # ==== Examples 
9   #
10   # Producing a SetElementsOperand from +set_operand+:
11   #
12   #   set_operand.elements
13   #
14   class SetElementsOperand 
15     include Gecode::Operand 
16 
17     # Constructs a new set elements operand +set+.
18     def initialize(set) #:nodoc:
19       unless set.respond_to? :to_set_var
20         raise TypeError, "Expected set operand, got #{set.class}."
21       end
22 
23       @set = set
24     end
25 
26     # Returns the set operand that makes up the set elements operand.
27     def to_set_elements #:nodoc:
28       return @set
29     end
30 
31     def model #:nodoc:
32       @set.model
33     end
34 
35     private
36 
37     def construct_receiver(params)
38       SetElementsConstraintReceiver.new(model, params)
39     end
40   end
41 
42   # SetElementsConstraintReceiver contains all constraints that can be
43   # placed on a SetElementsOperand.
44   #
45   # Constraints are placed by calling SetElementsOperand#must (or any other
46   # of the variations defined in Operand), which produces a 
47   # SetElementsConstraintReceiver from which the desired constraint can 
48   # be used.
49   #
50   # Each constraint accepts a number of options. See ConstraintReceiver
51   # for more information.
52   #
53   # ==== Examples 
54   #
55   # Constrains all elements in +set_operand+ to be strictly greater than 17
56   # using SetOperand#elements and SetElementsConstraintReceiver#>: 
57   #
58   #   set.elements.must > 17
59   #
60   # Constrains all elements in +set_operand+ to be strictly greater than
61   # +int_operand+ using SetOperand#elements and SetElementsConstraintReceiver#>:
62   #
63   #   set.elements.must > int_operand
64   #
65   # The same as above, but specifying that strength :domain should be 
66   # used and that the constraint should be reified with +bool_operand+:
67   #
68   #   set.elements.must_be.greater_than(int_operand, :strength => :domain, :reify => bool_operand)
69   #
70   class SetElementsConstraintReceiver < Gecode::ConstraintReceiver
71     # Raises TypeError unless the left hand side is set elements operand.
72     def initialize(model, params) #:nodoc:
73       super
74 
75       unless params[:lhs].respond_to? :to_set_elements
76         raise TypeError, 'Must have set elements operand as left hand side.'
77       end
78     end
79   end
80 end
81 
82 module Gecode::Set #:nodoc:
83   module SetOperand
84     # Produces a SetElementsOperand on which relation constraints can be placed that
85     # constrain all elements in the set.
86     #
87     # ==== Examples 
88     #
89     #   # The elements of +set+.
90     #   set.elements
91     def elements
92       Gecode::SetElements::SetElementsOperand.new(self)
93     end
94   end
95 end
96 
97 require 'gecoder/interface/constraints/set_elements/relation.rb'

Generated on Thu Jan 08 13:27:03 +0100 2015 with rcov 1.0.0