Sha256: 67e93414f0a2cef430c67963677599d8ebdce83647b6762a094febb6b736dab1
Contents?: true
Size: 834 Bytes
Versions: 1
Compression:
Stored size: 834 Bytes
Contents
# encoding: UTF-8 # frozen_string_literal: true module ArrayTweaks module Extension def drop_last slice(0, (size - 1).abs) # or slice(0...-1) end def drop_last! slice!(-1) end def each_with_index_and_size size = self.size each_with_index { |item, index| yield(item, index, size) } end def each_after(n) each_with_index do |item, i| yield(item) if i >= n end end def map_key(key) map { |item| item[key] } end end end Array.include ArrayTweaks::Extension module ObjectTweaks module Extension def not_in?(another_object) !another_object.include?(self) rescue NoMethodError raise ArgumentError, "The parameter passed to #not_in? must respond to #include?." end end end Object.include ObjectTweaks::Extension
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
array-tweaks-1.0.3 | lib/array-tweaks.rb |