Class: Elasticband::Query::ScoreFunction::ScoreMode

Inherits:
Elasticband::Query::ScoreFunction show all
Defined in:
lib/elasticband/query/score_function/score_mode.rb

Constant Summary collapse

MODES =
%i(multiply mult sum avg first max min).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode = nil) ⇒ ScoreMode

Returns a new instance of ScoreMode.



9
10
11
# File 'lib/elasticband/query/score_function/score_mode.rb', line 9

def initialize(mode = nil)
  self.mode = mode
end

Instance Attribute Details

#modeObject

Returns the value of attribute mode.



5
6
7
# File 'lib/elasticband/query/score_function/score_mode.rb', line 5

def mode
  @mode
end

Instance Method Details

#to_hObject



13
14
15
16
17
# File 'lib/elasticband/query/score_function/score_mode.rb', line 13

def to_h
  return {} unless mode && MODES.include?(mode)

  { score_mode: mode }
end