Class: Ranker::Strategies::Strategy

Inherits:
Object
  • Object
show all
Defined in:
lib/ranker/strategies/strategy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rankables, *args) ⇒ Strategy

Returns a new instance of Strategy.



7
8
9
10
11
12
13
14
15
# File 'lib/ranker/strategies/strategy.rb', line 7

def initialize(rankables, *args)
  @rankables = rankables
  options = args.pop
  if options && options.kind_of?(Hash)
    @options = default_options.merge(options)
  else
    @options = default_options
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/ranker/strategies/strategy.rb', line 5

def options
  @options
end

#rankablesObject (readonly)

Returns the value of attribute rankables.



5
6
7
# File 'lib/ranker/strategies/strategy.rb', line 5

def rankables
  @rankables
end

Instance Method Details

#rankObject



28
29
30
31
# File 'lib/ranker/strategies/strategy.rb', line 28

def rank
  execute
  rankings
end

#rankingsObject

Properties:



20
21
22
# File 'lib/ranker/strategies/strategy.rb', line 20

def rankings
  @rankings ||= Ranker::Rankings.new(self)
end