Module: WeightedListRank::Item

Defined in:
lib/weighted_list_rank/item.rb

Instance Method Summary collapse

Instance Method Details

#idInteger, String

Returns the unique identifier of the item. Must be implemented by including class.

Returns:

  • (Integer, String)

    the unique identifier of the item

Raises:

  • (NotImplementedError)


11
12
13
# File 'lib/weighted_list_rank/item.rb', line 11

def id
  raise NotImplementedError, "Implement this method to return the item's unique identifier"
end

#positionInteger

Returns the position of the item within its list. Must be implemented by including class.

Returns:

  • (Integer)

    the position of the item

Raises:

  • (NotImplementedError)


5
6
7
# File 'lib/weighted_list_rank/item.rb', line 5

def position
  raise NotImplementedError, "Implement this method to return the item's position"
end

#score_penaltyFloat, NilClass

Returns the score penalty of the item. Can be overridden by the including class.

Returns:

  • (Float, NilClass)

    the score penalty of the item as a percentage (e.g., 0.20 for 20%) or nil if no penalty



17
18
19
# File 'lib/weighted_list_rank/item.rb', line 17

def score_penalty
  nil
end