Namespace

Class/Module Index [+]

Quicksearch

Twitter::Utils

Public Class Methods

flat_pmap(enumerable) click to toggle source

Returns a new array with the concatenated results of running block once for every element in enumerable. If no block is given, an enumerator is returned instead.

@param enumerable [Enumerable] @return [Array, Enumerator]

# File lib/twitter/utils.rb, line 27
def flat_pmap(enumerable)
  return to_enum(:flat_pmap, enumerable) unless block_given?
  pmap(enumerable, &Proc.new).flatten!(1)
end
included(base) click to toggle source
# File lib/twitter/utils.rb, line 4
def included(base)
  base.extend(ClassMethods)
end
pmap(enumerable) click to toggle source

Returns a new array with the results of running block once for every element in enumerable. If no block is given, an enumerator is returned instead.

@param enumerable [Enumerable] @return [Array, Enumerator]

# File lib/twitter/utils.rb, line 38
def pmap(enumerable)
  return to_enum(:pmap, enumerable) unless block_given?
  if enumerable.count == 1
    enumerable.collect { |object| yield(object) }
  else
    enumerable.collect { |object| Thread.new { yield(object) } }.collect(&:value)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.