Class: Stretchy::Boosts::FilterBoost

Inherits:
Base
  • Object
show all
Defined in:
lib/stretchy/boosts/filter_boost.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_DECAY_FN, Base::DEFAULT_WEIGHT

Constants included from Utils::Contract

Utils::Contract::ASSERTIONS, Utils::Contract::DECAY_FUNCTIONS, Utils::Contract::DISTANCE_FORMAT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Contract

included, #require_one, #validate!

Constructor Details

#initialize(options = {}) ⇒ FilterBoost

Returns a new instance of FilterBoost.



13
14
15
16
17
# File 'lib/stretchy/boosts/filter_boost.rb', line 13

def initialize(options = {})
  @filter = options[:filter]
  @weight = options[:weight] || DEFAULT_WEIGHT
  validate!
end

Instance Attribute Details

#filterObject (readonly)

Returns the value of attribute filter.



8
9
10
# File 'lib/stretchy/boosts/filter_boost.rb', line 8

def filter
  @filter
end

#weightObject (readonly)

Returns the value of attribute weight.



8
9
10
# File 'lib/stretchy/boosts/filter_boost.rb', line 8

def weight
  @weight
end

Instance Method Details

#to_searchObject



19
20
21
22
23
24
# File 'lib/stretchy/boosts/filter_boost.rb', line 19

def to_search
  {
    filter: @filter.to_search,
    weight: @weight
  }
end