Sha256: b394c916d4de6f38287fcbda97d1ae7e9e268d6db2403e50788f530a8d8b69c5

Contents?: true

Size: 698 Bytes

Versions: 115

Compression:

Stored size: 698 Bytes

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 at.
  #
  # together_at has alias :tat
  #
  # same elements size case
  #   alpha = %w{one two three}
  #   numbers = %w{1 2 3}
  #   [alpha, numbers].together_at 2 # => output ['three', 3]
  #
  # different elements size case
  #   alpha = %w{one two three}
  #   numbers = %w{1 2}
  #   [alpha, numbers].together_at 2 # => output ['three', nil]
  def together_at(index)
    if_not_contain_array_rails_type_error
    reduce([]) { |ats, list|ats << list.at(index) }
  end

  alias_method :tat, :together_at
end

Version data entries

115 entries across 115 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.151 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.150 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.149 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.148 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.147 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.146 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.145 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.144 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.143 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.142 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.141 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.140 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.139 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.138 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.137 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.136 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.135 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.134 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.133 lib/open_classes/array/together_at.rb
tbpgr_utils-0.0.132 lib/open_classes/array/together_at.rb