Module: Vptree::CalcDistance

Included in:
VPNode, VPTree
Defined in:
lib/vptree.rb

Overview

Mixin for calculating distance in VPNode and VPTree compatable with Distance-measure gem

Instance Method Summary collapse

Instance Method Details

#calc_dist(obj1, obj2) ⇒ Object



38
39
40
41
42
43
# File 'lib/vptree.rb', line 38

def calc_dist(obj1, obj2)
  return @is_block ? obj1.distance(obj2, &@distance_measure) : obj1.distance(obj2, @distance_measure)
rescue
  # old fasion distance gem, for arrays only
  return @is_block ? @distance_measure.call(obj1, obj2) : obj1.send(@distance_measure, obj2)
end