Class: EhbrsRubyUtils::CircularListSpreader::List::ItemPairSpreadness

Inherits:
Object
  • Object
show all
Defined in:
lib/ehbrs_ruby_utils/circular_list_spreader/list/item_pair_spreadness.rb

Instance Method Summary collapse

Instance Method Details

#distanceInteger

Returns:

  • (Integer)


17
18
19
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/list/item_pair_spreadness.rb', line 17

def distance
  to_right_distance * to_left_distance
end

#left_pathArray

Returns:

  • (Array)


22
23
24
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/list/item_pair_spreadness.rb', line 22

def left_path
  list.items.fetch(left_index).item.to_circular_list_spreader_path
end

#resultInteger

Returns:

  • (Integer)


42
43
44
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/list/item_pair_spreadness.rb', line 42

def result
  similarity * distance
end

#right_pathArray

Returns:

  • (Array)


27
28
29
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/list/item_pair_spreadness.rb', line 27

def right_path
  item_on_index_path(right_index)
end

#to_left_distanceInteger

Returns:

  • (Integer)


32
33
34
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/list/item_pair_spreadness.rb', line 32

def to_left_distance
  right_index - left_index
end

#to_right_distanceInteger

Returns:

  • (Integer)


37
38
39
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/list/item_pair_spreadness.rb', line 37

def to_right_distance
  list.count - right_index + left_index
end