class ObjectSimilarity::FieldScorer

Attributes

field[R]
weight[R]

Public Class Methods

new(field, object, weight, options = {}) click to toggle source
# File lib/object_similarity.rb, line 10
def initialize(field, object, weight, options = {})
  @field = field
  @object = object
  @weight = weight || 1
  @options = options
end

Public Instance Methods

get_value(object) click to toggle source
# File lib/object_similarity.rb, line 27
def get_value(object)
  object.send(@field).tap do |v|
    raise SkipException if skip_value?(v)
  end
end
skip_value?(value) click to toggle source
# File lib/object_similarity.rb, line 34
def skip_value?(value)
  false
end
value() click to toggle source
# File lib/object_similarity.rb, line 21
def value
  @value ||= (@options[:value] || get_value(@object)).tap do |v|
    raise SkipException if skip_value?(v)
  end
end
weighted_distance(other_object) click to toggle source
# File lib/object_similarity.rb, line 17
def weighted_distance(other_object)
  distance(other_object) * @weight
end