Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
---|---|---|---|---|

lib/gecoder/interface/convenience.rb | 99 |
25 |
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 module Gecode |

2 # A convenient class that just includes Gecode::Mixin. Can be useful |

3 # when you don't want to create your own class that mixes in |

4 # Gecode::Mixin. |

5 class Model |

6 include Gecode::Mixin |

7 end |

8 |

9 # Provides a convenient way to construct a model and then find a |

10 # solution. The model constructed uses the specified block as |

11 # initialization method. The first solution to the model is then |

12 # returned. |

13 # |

14 # For instance |

15 # |

16 # solution = Gecode.solve do |

17 # # Do something |

18 # end |

19 # |

20 # is equivalent to |

21 # |

22 # class Foo |

23 # include Gecode::Mixin |

24 # |

25 # def initialize |

26 # # Do something |

27 # end |

28 # end |

29 # solution = Foo.new.solve! |

30 def self.solve(&block) |

31 create_model(&block).solve! |

32 end |

33 |

34 # Provides a convenient way to construct a model and then find the |

35 # solution that maximizes a given variable. The model constructed |

36 # uses the specified block as initialization method. The solution |

37 # that maximizes the specified variable is then returned. |

38 # |

39 # For instance |

40 # |

41 # solution = Gecode.maximize :variable_bar do |

42 # # Do something |

43 # end |

44 # |

45 # is equivalent to |

46 # |

47 # class Foo |

48 # include Gecode::Mixin |

49 # |

50 # def initialize |

51 # # Do something |

52 # end |

53 # end |

54 # solution = Foo.new.maximize :variable_bar |

55 def self.maximize(variable_to_maximize, &block) |

56 create_model(&block).maximize! variable_to_maximize |

57 end |

58 |

59 # Provides a convenient way to construct a model and then find the |

60 # solution that minimizes a given variable. The model constructed |

61 # uses the specified block as initialization method. The solution |

62 # that minimizes the specified variable is then returned. |

63 # |

64 # For instance |

65 # |

66 # solution = Gecode.minimize :variable_bar do |

67 # # Do something |

68 # end |

69 # |

70 # is equivalent to |

71 # |

72 # class Foo |

73 # include Gecode::Mixin |

74 # |

75 # def initialize |

76 # # Do something |

77 # end |

78 # end |

79 # solution = Foo.new.minimize :variable_bar |

80 def self.minimize(variable_to_minimize, &block) |

81 create_model(&block).minimize! variable_to_minimize |

82 end |

83 |

84 private |

85 |

86 # Creates an instance of a class that subclasses Model and uses the |

87 # specified block as initialization method. |

88 def self.create_model(&block) |

89 model = Class.new |

90 model.class_eval do |

91 include Gecode::Mixin |

92 |

93 def initialize(&init_block) #:nodoc: |

94 instance_eval &init_block |

95 end |

96 end |

97 model.new(&block) |

98 end |

99 end |

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