Class: Linkage::Expectations::Exhaustive
- Inherits:
-
Linkage::Expectation
- Object
- Linkage::Expectation
- Linkage::Expectations::Exhaustive
- Defined in:
- lib/linkage/expectations/exhaustive.rb
Instance Attribute Summary collapse
-
#comparator ⇒ Object
readonly
Returns the value of attribute comparator.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#threshold ⇒ Object
readonly
Returns the value of attribute threshold.
Instance Method Summary collapse
- #apply_to(dataset, side) ⇒ Object
-
#initialize(comparator, threshold, mode) ⇒ Exhaustive
constructor
A new instance of Exhaustive.
- #kind ⇒ Object
- #satisfied?(score) ⇒ Boolean
Methods inherited from Linkage::Expectation
Constructor Details
#initialize(comparator, threshold, mode) ⇒ Exhaustive
Returns a new instance of Exhaustive.
6 7 8 9 10 |
# File 'lib/linkage/expectations/exhaustive.rb', line 6 def initialize(comparator, threshold, mode) @comparator = comparator @threshold = threshold @mode = mode end |
Instance Attribute Details
#comparator ⇒ Object (readonly)
Returns the value of attribute comparator.
4 5 6 |
# File 'lib/linkage/expectations/exhaustive.rb', line 4 def comparator @comparator end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
4 5 6 |
# File 'lib/linkage/expectations/exhaustive.rb', line 4 def mode @mode end |
#threshold ⇒ Object (readonly)
Returns the value of attribute threshold.
4 5 6 |
# File 'lib/linkage/expectations/exhaustive.rb', line 4 def threshold @threshold end |
Instance Method Details
#apply_to(dataset, side) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/linkage/expectations/exhaustive.rb', line 42 def apply_to(dataset, side) exprs = case side when :lhs comparator.lhs_args.collect { |arg| arg.to_expr.as(arg.name) } when :rhs comparator.rhs_args.collect { |arg| arg.to_expr.as(arg.name) } end dataset.select_more(*exprs) end |
#kind ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/linkage/expectations/exhaustive.rb', line 12 def kind if @kind.nil? if @comparator.lhs_args.length != @comparator.rhs_args.length @kind = :cross else @kind = :self @comparator.lhs_args.each_with_index do |lhs_arg, index| rhs_arg = @comparator.rhs_args[index] if !lhs_arg.objects_equal?(rhs_arg) @kind = :cross break end end end # Check for dual-linkage. if @kind == :cross # Assume that all lhs arguments have the same dataset, as well # as all the rhs arguments. Only check the first argument of each # side. lhs_arg = @comparator.lhs_args[0] rhs_arg = @comparator.rhs_args[0] if !lhs_arg.datasets_equal?(rhs_arg) @kind = :dual end end end @kind end |
#satisfied?(score) ⇒ Boolean
53 54 55 56 57 58 59 60 |
# File 'lib/linkage/expectations/exhaustive.rb', line 53 def satisfied?(score) case mode when :equal score == threshold when :min score >= threshold end end |