module Augmented::Arrays::Tieable

Public Instance Methods

tie(object = nil, &block) click to toggle source
# File lib/augmented/arrays/tieable.rb, line 6
def tie object = nil, &block
  raise ArgumentError, 'you must provide a non-nil tie object or block' if object.nil? && !block_given?

  tie_function = block_given? ? block : proc{ object }
  ties = self.each_cons(2).map(&tie_function)

  self.zip(ties).flatten(1)[0...-1]
end