Class: Linkage::Comparators::Within
- Inherits:
-
Binary
show all
- Defined in:
- lib/linkage/comparators/within.rb
Constant Summary
collapse
- @@parameters =
[
[:any, :static => false, :side => :first],
[Fixnum],
[:any, :same_type_as => 0, :static => false, :side => :second]
]
- @@comparator_name =
'within'
Instance Attribute Summary
#args, #lhs_args, #rhs_args
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Binary
score_range
[], register, score_range
Constructor Details
#initialize(*args) ⇒ Within
Returns a new instance of Within.
18
19
20
21
22
23
|
# File 'lib/linkage/comparators/within.rb', line 18
def initialize(*args)
super
@name_1 = @args[0].name
@value = @args[1].object
@name_2 = @args[2].name
end
|
Class Method Details
.comparator_name ⇒ Object
14
15
16
|
# File 'lib/linkage/comparators/within.rb', line 14
def self.comparator_name
@@comparator_name
end
|
.parameters ⇒ Object
9
10
11
|
# File 'lib/linkage/comparators/within.rb', line 9
def self.parameters
@@parameters
end
|
Instance Method Details
#score(record_1, record_2) ⇒ Object
25
26
27
|
# File 'lib/linkage/comparators/within.rb', line 25
def score(record_1, record_2)
(record_1[@name_1] - record_2[@name_2]).abs <= @value ? 1 : 0
end
|