module Enumerable

Copyright © 2010-2017 GoodData Corporation. All rights reserved. This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree.

Public Instance Methods

ljust(n, x) click to toggle source
# File lib/gooddata/extensions/enumerable.rb, line 33
def ljust(n, x)
  dup.fill(x, length...n)
end
mapcat(initial = [], &block) click to toggle source
# File lib/gooddata/extensions/enumerable.rb, line 5
def mapcat(initial = [], &block)
  reduce(initial) do |a, e|
    block.call(e).each do |x|
      a << x
    end
    a
  end
end
pmapcat(initial = [], &block) click to toggle source
# File lib/gooddata/extensions/enumerable.rb, line 14
def pmapcat(initial = [], &block)
  intermediate = pmap(&block)
  intermediate.reduce(initial) do |a, e|
    e.each do |x|
      a << x
    end
    a
  end
end
pselect(&block) click to toggle source
# File lib/gooddata/extensions/enumerable.rb, line 24
def pselect(&block)
  intermediate = pmap(&block)
  zip(intermediate).select { |x| x[1] }.map(&:first)
end
rjust(n, x) click to toggle source
# File lib/gooddata/extensions/enumerable.rb, line 29
def rjust(n, x)
  Array.new([0, n - length].max, x) + self
end