Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
---|---|---|---|---|
lib/gecoder/interface/constraints/selected_set_constraints.rb | 75 | 34 | 100.00%
|
100.00%
|
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.
1 # A module containing constraints that have set_enum[set] as left hand |
2 # side. |
3 module Gecode::SelectedSet #:nodoc: |
4 # A SelectedSetOperand is an uncommon operand that results from calling |
5 # SetEnumOperand#[] with a SetOperand. It facilitates placing the |
6 # constraints defined in SelectedSetConstraintReceiver |
7 # |
8 # ==== Examples |
9 # |
10 # Producing a SelectedSetOperand from +set_enum+ and +set_operand+: |
11 # |
12 # set_enum[set_operand] |
13 # |
14 class SelectedSetOperand |
15 include Gecode::Operand |
16 |
17 # Constructs a new selected set operand from +set_enum+ and +set+. |
18 def initialize(set_enum, set) #:nodoc: |
19 unless set_enum.respond_to? :to_set_enum |
20 raise TypeError, "Expected set enum operand, got #{set_enum.class}." |
21 end |
22 unless set.respond_to? :to_set_var |
23 raise TypeError, "Expected set operand, got #{set.class}." |
24 end |
25 |
26 @set_enum = set_enum |
27 @set = set |
28 end |
29 |
30 # Returns the set enum and set that make up the selected set |
31 # operand. |
32 def to_selected_set #:nodoc: |
33 return @set_enum, @set |
34 end |
35 |
36 def model #:nodoc: |
37 @set_enum.model |
38 end |
39 |
40 private |
41 |
42 def construct_receiver(params) |
43 SelectedSetConstraintReceiver.new(model, params) |
44 end |
45 end |
46 |
47 # SelectedSetConstraintReceiver contains all constraints that can be |
48 # placed on a SelectedSetOperand. |
49 # |
50 # Constraints are placed by calling SelectedSetOperand#must (or any other |
51 # of the variations defined in Operand), which produces a |
52 # SelectedSetConstraintReceiver from which the desired constraint can |
53 # be used. |
54 # |
55 # ==== Examples |
56 # |
57 # Constrains the sets in +set_enum+ that are selected by +set_operand+ to be |
58 # disjoint. This uses SetEnumOperand#[] and |
59 # SelectedSetConstraintReceiver#disjoint. |
60 # |
61 # set_enum[set_operand].must_be.disjoint |
62 # |
63 class SelectedSetConstraintReceiver < Gecode::ConstraintReceiver |
64 # Raises TypeError unless the left hand side is a selected set operand. |
65 def initialize(model, params) #:nodoc: |
66 super |
67 |
68 unless params[:lhs].respond_to? :to_selected_set |
69 raise TypeError, 'Must have selected set operand as left hand side.' |
70 end |
71 end |
72 end |
73 end |
74 |
75 require 'gecoder/interface/constraints/selected_set/select' |
Generated on Thu Jan 08 13:27:03 +0100 2015 with rcov 1.0.0