Class: Stretchy::Boosts::FieldDecayBoost
- Defined in:
- lib/stretchy/boosts/field_decay_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
-
#decay ⇒ Object
readonly
Returns the value of attribute decay.
-
#decay_amount ⇒ Object
readonly
Returns the value of attribute decay_amount.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#scale ⇒ Object
readonly
Returns the value of attribute scale.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ FieldDecayBoost
constructor
A new instance of FieldDecayBoost.
- #to_search ⇒ Object
Methods included from Utils::Contract
included, #require_one, #validate!
Constructor Details
#initialize(options = {}) ⇒ FieldDecayBoost
Returns a new instance of FieldDecayBoost.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/stretchy/boosts/field_decay_boost.rb', line 16 def initialize( = {}) @field = [:field] @origin = [:origin] @scale = [:scale] @offset = [:offset] @type = [:type] || DEFAULT_DECAY_FN @weight = [:weight] || DEFAULT_WEIGHT @decay = [:decay] validate! end |
Instance Attribute Details
#decay ⇒ Object (readonly)
Returns the value of attribute decay.
8 9 10 |
# File 'lib/stretchy/boosts/field_decay_boost.rb', line 8 def decay @decay end |
#decay_amount ⇒ Object (readonly)
Returns the value of attribute decay_amount.
8 9 10 |
# File 'lib/stretchy/boosts/field_decay_boost.rb', line 8 def decay_amount @decay_amount end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
8 9 10 |
# File 'lib/stretchy/boosts/field_decay_boost.rb', line 8 def field @field end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
8 9 10 |
# File 'lib/stretchy/boosts/field_decay_boost.rb', line 8 def offset @offset end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
8 9 10 |
# File 'lib/stretchy/boosts/field_decay_boost.rb', line 8 def origin @origin end |
#scale ⇒ Object (readonly)
Returns the value of attribute scale.
8 9 10 |
# File 'lib/stretchy/boosts/field_decay_boost.rb', line 8 def scale @scale end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
8 9 10 |
# File 'lib/stretchy/boosts/field_decay_boost.rb', line 8 def weight @weight end |
Instance Method Details
#to_search ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/stretchy/boosts/field_decay_boost.rb', line 29 def to_search json = {scale: @scale} if @origin.is_a?(Stretchy::Types::Base) json[:origin] = @origin.to_search else json[:origin] = @origin end json[:offset] = @offset if @offset json[:decay] = @decay if @decay { @type => { @field => json }, weight: @weight } end |