module ArrayTweaks::Extension
Public Instance Methods
drop_last()
click to toggle source
# File lib/array-tweaks.rb, line 6 def drop_last slice(0, (size - 1).abs) # or slice(0...-1) end
drop_last!()
click to toggle source
# File lib/array-tweaks.rb, line 10 def drop_last! slice!(-1) end
each_after(n) { |item| ... }
click to toggle source
# File lib/array-tweaks.rb, line 19 def each_after(n) each_with_index do |item, i| yield(item) if i >= n end end
each_with_index_and_size() { |item, index, size| ... }
click to toggle source
# File lib/array-tweaks.rb, line 14 def each_with_index_and_size size = self.size each_with_index { |item, index| yield(item, index, size) } end
map_key(key)
click to toggle source
# File lib/array-tweaks.rb, line 25 def map_key(key) map { |item| item[key] } end