Class: EhbrsRubyUtils::CircularListSpreader::List
- Inherits:
-
Object
- Object
- EhbrsRubyUtils::CircularListSpreader::List
show all
- Defined in:
- lib/ehbrs_ruby_utils/circular_list_spreader/list.rb,
lib/ehbrs_ruby_utils/circular_list_spreader/list/item_pair_spreadness.rb
Defined Under Namespace
Classes: ItemPairSpreadness
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.empty ⇒ Object
11
12
13
|
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/list.rb', line 11
def empty
new([], 0)
end
|
Instance Method Details
#insert(position, item_level) ⇒ Object
21
22
23
24
25
|
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/list.rb', line 21
def insert(position, item_level)
dup_items = items.dup
dup_items.insert(position, item_level)
self.class.new(dup_items, position)
end
|
#items_pair_enumerator ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/list.rb', line 27
def items_pair_enumerator
::Enumerator.new do |enum|
(count - 1).times do |li|
((li + 1)..(count - 1)).each do |ri|
enum.yield(li, ri)
end
end
end
end
|
#to_s ⇒ Object
37
38
39
|
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/list.rb', line 37
def to_s
items.map { |i| i.item.to_s }.join(', ')
end
|