Sha256: 3fd0aee0b7c249fff09cfe8e1c06abba407a3467e251368939b15d6a18091406

Contents?: true

Size: 1.17 KB

Versions: 115

Compression:

Stored size: 1.17 KB

Contents

# encoding: utf-8
require 'open_classes/object'
require 'open_classes/module'
require 'open_classes/array/together_helper'

# Array
class Array
  include TogetherHelper

  # Arrays bulk delete_at.
  #
  # together_delete_at has alias :tdelete_at
  #
  # if delete_at target is exist
  #   child1 = [1, 2, 3, 4]
  #   child2 = [2, 3, 4, 5]
  #   lists = [child1, child2]
  #   ret = lists.together_delete_at 2
  #   print ret # => [3, 4]
  #   print lists # => output [[1, 2, 4], [2, 3, 5]]
  #
  # if delete_at target is not exist
  #   child1 = [1, 2, 3, 4]
  #   child2 = [2, 3, 4, 5]
  #   lists = [child1, child2]
  #   ret = lists.together_delete_at 6
  #   print ret # => [nil, nil]
  #   print lists # => output [[1, 2, 3, 4], [2, 3, 4, 5]]
  #
  # if delete_at target is exist(minus index)
  #   child1 = [1, 2, 3, 4]
  #   child2 = [2, 3, 4, 5]
  #   lists = [child1, child2]
  #   ret = lists.together_delete_at -3
  #   print ret # => [2, 3]
  #   print lists # => output [[1, 3, 4], [2, 4, 5]]
  def together_delete_at(index)
    if_not_contain_array_rails_type_error
    reduce([]) { |ret, list|ret << list.delete_at(index) }
  end

  alias_method :tdelete_at, :together_delete_at
end

Version data entries

115 entries across 115 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.91 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.90 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.89 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.88 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.87 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.86 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.85 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.84 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.83 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.82 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.81 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.80 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.79 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.78 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.77 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.76 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.75 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.74 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.73 lib/open_classes/array/together_delete_at.rb
tbpgr_utils-0.0.72 lib/open_classes/array/together_delete_at.rb